ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   assigning variables (https://www.excelbanter.com/excel-programming/442026-assigning-variables.html)

howard

assigning variables
 
I have a problem that's new to me. I have a column, say B2 through B15.
There aare names in say the first 8 cells. Elsewhere in the code, I do
things with these names; for example I sort these names. Sometimes the
number of names will change. I may have 8 cells with names, and I will need
to change this to 7 cells with names or 9 cells with names. Because the
number of cells with names changes sometimes, and this reference is used in a
number of places in macros and VBA, I would like to assign a variable to the
number of cells, i.e. (variable 'a' = cells B2 thru B9), and then use this
variable insteal of the cell references. This way, if I have to add or
delete a name from the cells, I only have to do it in one place. Any
suggestions?
Thanks, Howard
--
Howard

joel[_930_]

assigning variables
 

LastRow = Range("B" & rows.count).end(xlup).row
Set MyRange = Range("B2:B" & LastRow)


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198523

http://www.thecodecage.com/forumz



All times are GMT +1. The time now is 12:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com