Forum Discussion
VBA code to Script
Hi guys,
I am new with Scripts, any help is appreciated.
I have a VBA code that works in an excel file but not in a shared file. So I am trying to convert the functions of the VBA code to a script but it keeps showing error.
This is the VBA code:
Sub Add_days()
Dim Lr As Long, Ws As Worksheet
Set Ws1 = Worksheets("Fre")
Set Ws2 = Worksheets("P")
Set Ws3 = Worksheets("D")
Lr1 = Ws1.Range("EGT" & Rows.Count).End(xlUp).Row
Ws1.Range("EGT2:EKK" & Lr1).Copy Ws1.Cells(2, Ws1.Columns.Count).End(xlToLeft).Offset(0, 1)
Lr2 = Ws2.Range("JGA" & Rows.Count).End(xlUp).Row
Ws2.Range("JGA2:JJR" & Lr2).Copy Ws2.Cells(2, Ws2.Columns.Count).End(xlToLeft).Offset(0, 1)
Lr3 = Ws3.Range("FGO" & Rows.Count).End(xlUp).Row
Ws3.Range("FGO2:FKF" & Lr3).Copy Ws3.Cells(2, Ws3.Columns.Count).End(xlToLeft).Offset(0, 1)
End Sub
I tried this in Script but it's throwing me an error (marking with bold where the error is):