(Solved) – How to make a same macro work for multiple sheets

  • by
(solved)-–-how-to-make-a-same-macro-work-for-multiple-sheets

I’m a vba beginner here, I have a code, which does copying a range and transfer the values in a next blank row continuously, for a specific single sheet, but what i want is the same copy and transfer work to be done in multiple worksheets in a single go. I am not knowing of how to assign multiple sheet names in the macro.
Here’s the code, it does work only for specific worksheet:

Option Explicit
Dim myTimer As Date

Sub GetMyData1()
Application.ScreenUpdating = False
Dim lastrow As Long, nextblankrow As Long
myTimer = Now   TimeValue("00:02:00")
Application.OnTime myTimer, "GetMyData1"
Dim rng1 As Range
Set rng1 = Worksheets("Adata").Range("A2:P2")
rng1.Copy
lastrow = Sheets("Adata").Range("A" & Rows.Count).End(xlUp).Row
nextblankrow = lastrow   1
Sheets("Adata").Range("A" & nextblankrow).PasteSpecial xlPasteValues
ActiveWorkbook.RefreshAll
Application.ScreenUpdating = True
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *