karenbluez
New Member
- Joined
- Apr 29, 2009
- Messages
- 18
I've got the following problem with my code on Excel 2007 (Must work however on 2003 for our legacy systems). I'm trying to get the ranges selected, and get the values in ranges to multiply by negative 1 to switch the signs around.
Every second time I run it I get an error message where it has to select the Budget range. (Error message: Run time error 1004, Select method of range class failed)
Any help will be super greatly appreciated!!!
Every second time I run it I get an error message where it has to select the Budget range. (Error message: Run time error 1004, Select method of range class failed)
Any help will be super greatly appreciated!!!
Code:
Set ws1 = Worksheets("Actual")
Set ws2 = Worksheets("Budget")
Set ws3 = Worksheets("Forecast")
Set Actual_Rng = Application.Union(Range("C88:AM101"), Range("C103:AM114"), Range("C116:AM131"), Range("C143:AM156"), Range("C158:AM169"), Range("C170:AM186"), Range("C198:AM211"), Range("C213:AM224"), Range("C226:AM241"), Range("C253:AM266"), Range("C268:AM279"), Range("C281:AM296"))
Set Budget_Rng = Application.Union(Range("C88:AL101"), Range("C103:AL114"), Range("C116:AL131"), Range("C143:AL156"), Range("C158:AL169"), Range("C170:AL186"), Range("C198:AL211"), Range("C213:AL224"), Range("C226:AL241"), Range("C253:AL266"), Range("C268:AL279"), Range("C281:AL296"))
Set Forecast_Rng = Application.Union(Range("C88:R101"), Range("C103:R114"), Range("C116:R131"), Range("C143:R156"), Range("C158:R169"), Range("C170:R186"), Range("C198:R211"), Range("C213:R224"), Range("C226:R241"), Range("C253:R266"), Range("C268:R279"), Range("C281:R296"))
ws1.Select
ws1.Range("A1") = -1
ws1.Range("A1").Copy
Actual_Rng.Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, SkipBlanks:=False, Transpose:=False
ws2.Select
ws2.Range("A1") = -1
ws2.Range("A1").Copy
Budget_Rng.Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, SkipBlanks:=False, Transpose:=False
ws3.Select
ws3.Range("A1") = -1
ws3.Range("A1").Copy
Forecast_Rng.Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, SkipBlanks:=False, Transpose:=False