Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 542
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigning a Variable to an Expression that Includes a Variable andVBA Property bluebird[_3_] Excel Programming 3 April 27th 09 07:38 AM
Assigning cell value to range variable Raj[_2_] Excel Programming 2 July 31st 08 05:44 PM
Assigning a variable a value from a Cell in VBA [email protected] Excel Programming 3 February 15th 06 06:26 PM
How can I use a variable as cell address? Matt[_33_] Excel Programming 9 September 27th 05 09:01 PM
Assigning cell address components to variables Conan Kelly Excel Programming 1 June 15th 05 06:05 AM


All times are GMT +1. The time now is 08:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"