Suppose
Sheets("Sheet1").Activate
Dim Begin as Range
Set Begin = Range("A10")
When I use
Sheets("Sheet2").Activate
Begin seems not the Range("A10") in Sheet2, then how to make the Begin become the Range("A10") in Sheet2?
I show my full code following, you can see that for each loop, I want deal with each sheet for same operation. But my code seems very tedious, and if I want to change Range("A10") to Range("A9"), then I should change each one manually.
Module1.Re() will also use Range("A10"), actually in each loop, I want to pass the variable Range("A10").Offset(i,0) into each sheet, but it is the cell in the corresponding sheet.
That's why I want to replace Range("A10") by a common variable Begin. Could you help me to simplify my code, actually I am totally new in VBA.
In Modules2
Sub Main()
Sheets("Sheet1").Activate
Z = 5
Y = 10
Dim Column As Integer
Dim Row As Integer
Set Begin = Range("A10")
Row = Begin.End(xlDown).Row - Begin.Row
For i = 1 To Row
Sheets("1 HK").Activate
Module1.Re (i)
Sheets("5 HK").Activate
Module1.Re (i)
Sheets("1 HK").Activate
Set Begin1 = Range("A10").Offset(i + 1, 4)
Set Begin2 = Range("A10").Offset(i + Z, 4 + Y)
Range(Begin1, Begin2).Clear
Sheets("5 HK").Activate
Set Begin1 = Range("A10").Offset(i + 1, 4)
Set Begin2 = Range("A10").Offset(i + Z, 4 + Y)
Range(Begin1, Begin2).Clear
Next i
End Sub