Reputation:
I was just wondering if there is a short and simple way to store the row number of cell location into an array. I have only been to store the entire cell location using the '.Address' vba function but I don't want the columns referenced so I can maniuplate the arrays later on in my sub.
Upvotes: 1
Views: 4382
Reputation: 26591
If you want to get the row of a range, you can use the row
property :
Dim myCell as Range
Dim myRow as Long
myRow = myCell.row
You can, of course, store the row in an array.
By the way, here are some tips about rows and columns : http://www.exceltip.com/excel_tips/Cells,_Ranges,_Rows,_and_Columns_in_VBA/204.html
Regards,
Max
Upvotes: 1
Reputation: 8441
Try:
Sub HTH()
Dim rCell As Range
Dim vMyArray() As Variant
Dim iLoop As Integer
For Each rCell In Range("A1:A10")
ReDim Preserve vMyArray(iLoop)
vMyArray(iLoop) = rCell.Row
iLoop = illop + 1
Next rCell
End Sub
Upvotes: 1