I am trying to find the number of columns and rows containing info in a sheet that will potentially change every update.
I have it figured out except the activecell.offset.activate seems to work except it won't allow me to use a variable.
The code I am using is this
Dim x As Integer ' number of columns
Dim y As Integer ' number of rows
Sub read()
x = 0
y = 0
Sheets("test").activate
Range("A1").Select
Do
Do
If ActiveCell.Value <> "" Then
ActiveCell.Offset(rowoffset:=0, columnoffset:=1).activate
x = x + 1
End If
Loop Until ActiveCell.Value = ""
ActiveCell.Offset(rowoffset:=0, columnoffset:=-x).activate
ActiveCell.Offset(rowoffset:=1, columnoffset:=0).activate
y = y + 1
Loop Until ActiveCell.Value = ""
MsgBox x
MsgBox y
End Sub
It is probably an easy answer but I am stuck.
Thanks in advance.
sgreni
Bookmarks