Hi there,
I am a relatively new user with VBA and have survived thus far with visiting billiant forums like this one, or alternatively playing around in VBA until I manage to solve the problem myself.
However this problem has me stumped and I need some help please.
The code is supposed to select the same variable range in 2 sheets and delete the entire rows in these sheets. I get a "Select method of Range class failed" error on the red line of code below.
As I mentioned, new user, so please be gentle.
Thanks
Sub Reset()
Dim Range1 AsRange
Dim Range2 AsRange
Dim Range3 AsRange
Dim Range4 AsRange
Dim Range5 AsRange
Dim Range6 AsRange
Dim Range8 AsRange
Set Range1 =Range("C4:C" & Range("CurrentDeals") + 2)
Set Range2 =Range("C" & Range("CurrentDeals") + 7 &":C" & Range("CurrentDeals") * 2 + 5)
Set Range3 =Range("C" & Range("CurrentDeals") * 2 + 12 &":C" & Range("CurrentDeals") * 3 + 10)
Set Range4 =Range("C" & Range("CurrentDeals") * 3 + 12 &":C" & Range("CurrentDeals") * 4 + 10)
Set Range5 =Range("C" & Range("CurrentDeals") * 4 + 12 &":C" & Range("CurrentDeals") * 5 + 10)
Set Range6 =Range("C" & Range("CurrentDeals") * 5 + 12 &":C" & Range("CurrentDeals") * 6 + 10)
Set Range7 =Range("C" & Range("CurrentDeals") * 6 + 12 &":C" & Range("CurrentDeals") * 7 + 10)
Set Range8 =Range("C" & Range("CurrentDeals") * 7 + 12 &":C" & Range("CurrentDeals") * 8 + 10)
Sheets("Forecast Income").Select
Union(Range1,Range2, Range3, Range4, Range5, Range6, Range7, Range8).Select
Selection.EntireRow.Delete
Range("A1").Select
Sheets("Forecast Expense").Select
Union(Range1,Range2, Range3, Range4, Range5, Range6, Range7, Range8).Select
Selection.EntireRow.Delete
Range("A1").Select
Sheets("Instructions").Select
Range("M3").Select
Selection.ClearContents
Range("A1").Select
End Sub
I am a relatively new user with VBA and have survived thus far with visiting billiant forums like this one, or alternatively playing around in VBA until I manage to solve the problem myself.
However this problem has me stumped and I need some help please.
The code is supposed to select the same variable range in 2 sheets and delete the entire rows in these sheets. I get a "Select method of Range class failed" error on the red line of code below.
As I mentioned, new user, so please be gentle.
Thanks
Sub Reset()
Dim Range1 AsRange
Dim Range2 AsRange
Dim Range3 AsRange
Dim Range4 AsRange
Dim Range5 AsRange
Dim Range6 AsRange
Dim Range8 AsRange
Set Range1 =Range("C4:C" & Range("CurrentDeals") + 2)
Set Range2 =Range("C" & Range("CurrentDeals") + 7 &":C" & Range("CurrentDeals") * 2 + 5)
Set Range3 =Range("C" & Range("CurrentDeals") * 2 + 12 &":C" & Range("CurrentDeals") * 3 + 10)
Set Range4 =Range("C" & Range("CurrentDeals") * 3 + 12 &":C" & Range("CurrentDeals") * 4 + 10)
Set Range5 =Range("C" & Range("CurrentDeals") * 4 + 12 &":C" & Range("CurrentDeals") * 5 + 10)
Set Range6 =Range("C" & Range("CurrentDeals") * 5 + 12 &":C" & Range("CurrentDeals") * 6 + 10)
Set Range7 =Range("C" & Range("CurrentDeals") * 6 + 12 &":C" & Range("CurrentDeals") * 7 + 10)
Set Range8 =Range("C" & Range("CurrentDeals") * 7 + 12 &":C" & Range("CurrentDeals") * 8 + 10)
Sheets("Forecast Income").Select
Union(Range1,Range2, Range3, Range4, Range5, Range6, Range7, Range8).Select
Selection.EntireRow.Delete
Range("A1").Select
Sheets("Forecast Expense").Select
Union(Range1,Range2, Range3, Range4, Range5, Range6, Range7, Range8).Select
Selection.EntireRow.Delete
Range("A1").Select
Sheets("Instructions").Select
Range("M3").Select
Selection.ClearContents
Range("A1").Select
End Sub