Assigning a cell address to a variable

J

James

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
 
M

Mike H

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top