Hi,
I'm new to programming in general and looking at learning VBA due to the fact my work has endless copy and paste spreadsheets that do my nut in!
I've produced a simple copy and paste from one workbook to another via the Macro Recorder and then I've cleaned it up a bit.
What could i do to improve it
![]()
Sub CopyFromAnotherWorkbook() ' CopyFromAnotherWorkbook - Copy data from Previous 7 days service disruption.xlsm to MI&SD Tracking.xlsm Dim LastRowColB As Long 'Count last row in Previous 7 days service disruption.xlsm Dim FinalRowColA As Integer 'Count last row in MI&SD Tracking.xlsm Dim Path As String Path = ThisWorkbook.Path & "\" Application.ScreenUpdating = False Application.Workbooks.Open (Path & "Previous 7 days Service Disruptions.xlsm") Worksheets("Report 1").Activate LastRowColB = Range("b65536").End(xlUp).Row 'Get Region code and autofill Range("H5").Formula = "=TRIM(LEFT(F5,FIND(""SD"",F5)-1))" Range("H5").Select Selection.AutoFill Destination:=Range("H5:H" & LastRowColB) 'Copy Data in Previous 7 days service disruption.xlsm Range("B5:K" & LastRowColB).Select Selection.Copy 'Activate MI&SD Tracking.xlsm and Activate SD Raw Data Worksheet Windows("MI&SD Tracking.xlsm").Activate Worksheets("SD Raw Data").Activate 'Find row to paste new data to end of current data FinalRowColA = Range("A65536").End(xlUp).Row Range("A" & FinalRowColA + 1).Select 'Paste Data Selection.PasteSpecial Paste:=xlPasteValues Application.DisplayAlerts = False Workbooks("Previous 7 days Service Disruptions.xlsm").Close Application.DisplayAlerts = True Application.ScreenUpdating = False End Sub
Bookmarks