Forum Discussion
Taan87
Jun 08, 2019Copper Contributor
Macro in Excel
I’m new to Macro in excel and I was wondering on how to apply macro rules on previous sheets without the rule looking for the sheet name and not the order of sheets. Example. I use excel for finance...
Berndvbatanker
Jun 08, 2019Iron Contributor
Hi,
you don't need to select ranges and sheets. For example...
Sub GetDataFromSheetBefore()
Dim i As Integer
For i = 2 To Worksheets.Count
Worksheets(i).Range("A1:A2").Value = Worksheets(i - 1).Range("A1:A2").Value
Next i
End Sub
Regards
Bernd
http://www.vba-Tanker.com