Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Assigning a cell address to a variable
I'm sure this is a simple question, but I've been searching and cannot seem
to find the answer to it. I have a couple of loops that run that put data onto a spreadsheet, I want to before the loop runs assign a variable the address of the first cell and at the end assign a variable the address of the last cell. I am trying to use Set LastDay = Range(Cells(3, CalCount)) but this gives me an error. Any ideas or help I would love. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Assigning a cell address to a variable
James,
This would set the variable LastDay to the address of the last used cell in column A and then create a named range from A1 to that cell LastDay = "A" & Cells(Cells.Rows.Count, "A").End(xlUp).Row Set MyRange = Range("A1:" & LastDay) -- Mike When competing hypotheses are otherwise equal, adopt the hypothesis that introduces the fewest assumptions while still sufficiently answering the question. "James" wrote: I'm sure this is a simple question, but I've been searching and cannot seem to find the answer to it. I have a couple of loops that run that put data onto a spreadsheet, I want to before the loop runs assign a variable the address of the first cell and at the end assign a variable the address of the last cell. I am trying to use Set LastDay = Range(Cells(3, CalCount)) but this gives me an error. Any ideas or help I would love. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Assigning a Variable to an Expression that Includes a Variable andVBA Property | Excel Programming | |||
Assigning cell value to range variable | Excel Programming | |||
Assigning a variable a value from a Cell in VBA | Excel Programming | |||
How can I use a variable as cell address? | Excel Programming | |||
Assigning cell address components to variables | Excel Programming |