I have table tblActivties on sheet Activities and tblTrainingLog on sheet TrainReg. I want to copy two columns from tbleActivties and paste them in the corresponding columns on sheet TrainReg. The amount of columns to copy is known and the number of rows to copy in tblActivities in unknown (last row to be determined). There is already many filled rows in tblTrainingLog and I want the data to be pasted to the first blank cell. I have code to copy one column but not sure how to expand this to copying two columns. I need the fastest solution as I will be copy/pasting over 100 rows
[P.S. The top and bottom of my code is an attempt to speed up the code but I'm not sure if this is effective]
[P.S.S. I am very new to VBA so looking to build something basic and slowly upgrade as I learn more efficient code]
QUESTION: How do i update code to copy range A10:B10 to lastrow in tblActivities in sheet Activities and paste data in first empty cell in tblTrainingReg in sheet TrainReg
Public Sub TurnOffFunctionality() 'To run code fast turn off certain VBA functionality at the start of our code. Turn it back on, at the end of our code.
Application.Calculation = xlCalculationManual
Application.DisplayStatusBar = False
Application.EnableEvents = False
Application.ScreenUpdating = False
End Sub
Private Sub CommandButton1_Click()
Dim lastrow As Long, nextrow As Long 'Define variable type lastrow and nextrow
lastrow = Worksheets("Activities").Cells(Rows.Count, 1).End(xlUp).Row 'Check the last filled line on sheet named TrainReg
For i = 10 To lastrow 'Loop will run from row 10 on Activities Sheet to last filled row in table
Worksheets("Activities").Cells(i, 2).Copy 'Copy the row
nextrow = Worksheets("TrainReg").Cells(Rows.Count, 13).End(xlUp).Row 'Evaluating how many rows are already filled in table TrainReg
Worksheets("Activities").Paste Destination:=Worksheets("TrainReg").Cells(nextrow + 1, 6)
Next i 'Closes loop
Worksheets("TrainReg").Activate 'Returns to TrainReg Sheet
Application.CutCopyMode = False
End Sub
Public Sub TurnOnFunctionality()
Application.Calculation = xlCalculationAutomatic
Application.DisplayStatusBar = True
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
[P.S. The top and bottom of my code is an attempt to speed up the code but I'm not sure if this is effective]
[P.S.S. I am very new to VBA so looking to build something basic and slowly upgrade as I learn more efficient code]
QUESTION: How do i update code to copy range A10:B10 to lastrow in tblActivities in sheet Activities and paste data in first empty cell in tblTrainingReg in sheet TrainReg
Public Sub TurnOffFunctionality() 'To run code fast turn off certain VBA functionality at the start of our code. Turn it back on, at the end of our code.
Application.Calculation = xlCalculationManual
Application.DisplayStatusBar = False
Application.EnableEvents = False
Application.ScreenUpdating = False
End Sub
Private Sub CommandButton1_Click()
Dim lastrow As Long, nextrow As Long 'Define variable type lastrow and nextrow
lastrow = Worksheets("Activities").Cells(Rows.Count, 1).End(xlUp).Row 'Check the last filled line on sheet named TrainReg
For i = 10 To lastrow 'Loop will run from row 10 on Activities Sheet to last filled row in table
Worksheets("Activities").Cells(i, 2).Copy 'Copy the row
nextrow = Worksheets("TrainReg").Cells(Rows.Count, 13).End(xlUp).Row 'Evaluating how many rows are already filled in table TrainReg
Worksheets("Activities").Paste Destination:=Worksheets("TrainReg").Cells(nextrow + 1, 6)
Next i 'Closes loop
Worksheets("TrainReg").Activate 'Returns to TrainReg Sheet
Application.CutCopyMode = False
End Sub
Public Sub TurnOnFunctionality()
Application.Calculation = xlCalculationAutomatic
Application.DisplayStatusBar = True
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub