View Full Version : Cells method advice

01-31-2007, 02:47 PM
When running this code:

Set shtrng1 = Sheets("data").Range("a1").CurrentRegion

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?

01-31-2007, 03:04 PM
With Sheets("data")
For i = 3 To c
.Range(.Cells((d-30), i), .Cells(d, i))
Next i
End With