Share via

convert VB to Office Script

Dayrak 41 Reputation points
2024-03-21T22:14:41.46+00:00

I have a maste sheet whic has the table that has been duplicated in sheet one to sheet 6 based on their criteria. I like to have the master sheet to be updated accordingly whenever data is entered into any table in sheets 1 to 6. from sheet 1 (rows 6 to 55), from sheet 2 (rows 56 to 300), from sheet 3 (rows 301 to 495), etc.

Although I made the power query which appends the tables from sheets 1 to 6, I like to have each row be copied and pasted to the master sheet when data is entered.

I have a script in VB individually for each sheet. wondering how I can convert it to an office script :

Sub CopyPasteSheet1()

'set variable

Dim wsSource As Worksheet

Dim wsTarget As Worksheet



'insert source and destination sheets

Set wsSource = Worksheets("Sheet1")

Set wsTarget = Worksheets("AfCL-L&N Precursors")



'copy data from the source

wsSource.Range("F6:Q55").Copy



'Paste data in the destination

Call wsTarget.Range("F195:Q244").PasteSpecial(Paste:=xlPasteValues)

End Sub

Thanks & Regards

 

Thanks & Regards,

Microsoft 365 and Office | Development | Other
0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.