Hi,
I have a very simple macro that i use to divide a an entire column (besides the header row) by 1000...
Sub Macro1()
Const x As Long = 1000
Dim cl As Range
Dim rng As Range
Set rng = Sheet1.Range("d2", Range("d65536").End(xlUp)).SpecialCells(xlCellTypeConstants)
For Each cl In rng
cl.Value = cl.Value / x
Next cl
End Sub
It works fine as long as the macro is attached to the workbook in which I am trying to use it. If the macro is attached to the personal workbook, I get a runtime error when I attempt to run it...
Run-time error '1004':
Method 'Range' of object '_Worksheet' failed
When I hit Debug, this line is highlighted...
Set rng = Sheet1.Range("d2", Range("d65536").End(xlUp)).SpecialCells(xlCellTypeConstants)
There appears to be some confusion when the range is defined, but I don't see why which workbook the macro is attached to should make a difference.
I am VERY new to this, so any help would be appreciated.
Thanks,
Corey
Bookmarks