Hi,
Here is the the problem:
1. 2 Worksheets.
2. A table w/ data on the first one.
When I activate manually Sheet 1 and run the code it runs smoothly. But when I activate manually Sheet 2 and run the code it gives me an error message - Runtime error '91' - Object variable or With block not set.
And I really don't understand it 'cause in the code I do activate Sheets(1) before doing anything. So it's a mystery for my why it would not run correctly if launched from any sheets other than Sheets(1).
Sub Subtotals()
Dim A As Range
Dim B As Range
Dim Data_Raw_Cell As Range
Dim TTL_Cl As Integer
Dim TTL_Rw As Integer
Set A = Cells(1, 1)
TTL_Rw = Range(A, A.End(xlDown)).Count
TTL_Cl = Range(A, A.End(xlToRight)).Count
Sheets(1).Activate
For Rw = 1 To TTL_Rw
For Cl = 1 To TTL_Cl
Set B = Cells(Rw, Cl)
If IsNumeric(B) Then
Set Data_Raw_Cell = B
Exit For
End If
Next Cl
If IsNumeric(B) Then Exit For
Next Rw
Data_Raw_Cell.Activate
End Sub
Bookmarks