clvestin
01-31-2007, 02:47 PM
When running this code:
Set shtrng1 = Sheets("data").Range("a1").CurrentRegion
Sheets("data").Activate
c = shtrng1.Columns.Count
d = shtrng1.Rows.Count
'Set myrange = Nothing
For i = 3 To c
Set myrange = Sheets("data").Range(Cells((d-30), i), Cells(d, i))
Not the complete code obviously.
I get an Application or object error at the Set myrange line unless the Sheets("data").Activate line has run, ie it only works if "data" is the active sheet.
What am I doing wrong?
Set shtrng1 = Sheets("data").Range("a1").CurrentRegion
Sheets("data").Activate
c = shtrng1.Columns.Count
d = shtrng1.Rows.Count
'Set myrange = Nothing
For i = 3 To c
Set myrange = Sheets("data").Range(Cells((d-30), i), Cells(d, i))
Not the complete code obviously.
I get an Application or object error at the Set myrange line unless the Sheets("data").Activate line has run, ie it only works if "data" is the active sheet.
What am I doing wrong?