-
Cells method advice
When running this code:
[VBA]
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))[/VBA]
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?
-
[vba]
With Sheets("data")
For i = 3 To c
.Range(.Cells((d-30), i), .Cells(d, i))
...
Next i
End With
[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules