![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: May 2002
Posts: 5
|
i previously posted a question asking how to assign the value of a cell to a variable. now someone was kind enough to answer that question, but the answers i tested out only worked with constant variable references. in my situation, the row number must itself be a variable. is there a way to assign the value of the cell with row unknown and column a to a variable?
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Denver, Colorado USA
Posts: 4,014
|
Hi Laura,
If I understand your question correctly, you can assign a cell value to a variable, assuming you know the cell is in column A and you have a variable, say iRow which is computed, that contains the row number: VariableName = Worksheets("Sheet Name").Cells(iRow,"A").Value or VariableName = Worksheets("Sheet Name").Cells(iRow,1).Value which is more efficient. If the worksheet is the active sheet, then this can be shortened to: VariableName = Cells(iRow,1).Value Note: be sure to always declare your row variable (iRow in this example) as Long. Otherwise you won't be able to go past row 32767.
__________________
Keep Excelling. Damon VBAexpert Excel Consulting (My other life: http://damonostrander.com ) |
|
|
|
|
|
#3 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
In case you mean that the row #'s a moving target, if you want the last cell in column A:
Now you can work with n, e.g., n.value, n.Address(False, False), etc.... |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|