PDA

View Full Version : help with variable row size selection



Dfense
01-16-2008, 01:19 AM
I could use help in getting the line(s) of code to select a row starting at I10 and ending at "variable+I"10. The "variable" is a value from a cell on the active sheet.
For example if "variable"=5 then I want to select I10:N10.

I have been at this for awhile and would really appreciate the help.
thanks

Andy Pope
01-16-2008, 01:41 AM
Hi,

Something like this. Assumes the 'variable' value is in cell A1 on activesheet.
Creates a reference to the range, which you can then select is you think you must.


Sub X()

Dim rngData As Range
Dim lngNCols As Long

lngNCols = Range("A1")
Set rngData = Range("I10").Resize(1, lngNCols + 1)

MsgBox rngData.Address

End Sub

Dfense
01-16-2008, 10:45 AM
Thanks, you just saved me some serious time!!!