Hello!
I need to set a dynamic range for formatting a report. The number of rows and columns will change regularly, and not all of the rows will have data. I put this together based on research in this forum, but I'm getting a "Compile error: invalid or unqualified reference" on ".Cells". Can anyone help with correcting this? Thanks!!
I need to set a dynamic range for formatting a report. The number of rows and columns will change regularly, and not all of the rows will have data. I put this together based on research in this forum, but I'm getting a "Compile error: invalid or unqualified reference" on ".Cells". Can anyone help with correcting this? Thanks!!
Code:
Dim lrow As Long
Dim lcol As Long
Dim onerng As Range
With Sheets("Solutions by Location")
lrow = .Range("a" & .Rows.Count).End(xlUp).Row
lcol = .Cells(lrow, .Columns.Count).End(xlToLeft).Column
End With
Range("A2").Select
Set onerng = .Cells(lrow, 1).Resize(, lcol)
Range("onerng").Select
'continue with code to format the selection