Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

How to Dim a variable as a Cell?

On Excel, I'm trying to code a macro that involves selecting a range of cells, in which both the upper limit and the lower limit cells in the range are variables. How would I go about programming this?

More specifically:

I have a column A and a column B. I wish to select a range of cells from column A and merge them together. That range will be equal to the range of cells in column B that are NOT empty. So, for example:

If cells B1 to B15 aren't empty (and B16 is empty), then my macro will select the cells A1 to A15 (then merge them).

Update:

garbo: It's for use in a database, for quicker formatting. There won't be any text in the cells to merge. I'd really appreciate it if you can tell me how to code it.

2 Answers

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    You cannot do it as a Cell. You can do it as a Range.

    Dim c As Range

    Set c = Range("A1")

    c.Value = "AA"

    .

    Source(s): TaZ
  • 1 decade ago

    This is fairly easily accomplished with a macro. However, if your selected cells each contain a value your merged result will contain only the value in the first cell in the selected range.

    I am curious what your goal is in achieving that result.

Still have questions? Get your answers by asking now.