Hi,
I currently utilise the below macro, however the file is being used online. I cannot seem to find a suitable script that will copy and paste at the bottom of the table. Can anyone assist to convert the below vba macro to a excel script.
Sub CopyAndPasteToTable()
Dim SourceSheet As Worksheet
Dim TargetSheet As Worksheet
Dim SourceRange As Range
Dim TargetTable As ListObject
Dim NewRow As ListRow
' Set the source and target worksheets
Set SourceSheet = ThisWorkbook.Worksheets("Daily Counts")
Set TargetSheet = ThisWorkbook.Worksheets("RTS")
' Set the source range
Set SourceRange = SourceSheet.Range("B27:C27")
' Set the target table
Set TargetTable = TargetSheet.ListObjects("RTS")
' Add a new row to the target table
Set NewRow = TargetTable.ListRows.Add
' Copy the source range and paste it into the new row
SourceRange.Copy
NewRow.Range(1, 1).PasteSpecial Paste:=xlPasteValues
' Clear the clipboard
Application.CutCopyMode = False
End Sub
I currently utilise the below macro, however the file is being used online. I cannot seem to find a suitable script that will copy and paste at the bottom of the table. Can anyone assist to convert the below vba macro to a excel script.
Sub CopyAndPasteToTable()
Dim SourceSheet As Worksheet
Dim TargetSheet As Worksheet
Dim SourceRange As Range
Dim TargetTable As ListObject
Dim NewRow As ListRow
' Set the source and target worksheets
Set SourceSheet = ThisWorkbook.Worksheets("Daily Counts")
Set TargetSheet = ThisWorkbook.Worksheets("RTS")
' Set the source range
Set SourceRange = SourceSheet.Range("B27:C27")
' Set the target table
Set TargetTable = TargetSheet.ListObjects("RTS")
' Add a new row to the target table
Set NewRow = TargetTable.ListRows.Add
' Copy the source range and paste it into the new row
SourceRange.Copy
NewRow.Range(1, 1).PasteSpecial Paste:=xlPasteValues
' Clear the clipboard
Application.CutCopyMode = False
End Sub