Vba Append data to multiple tables across multiple sheets

Melimob

Active Member
Joined
Oct 16, 2011
Messages
396
Office Version
  1. 365
Hi I think I am NEARLY there with this but not working exactly how I need.

At the moment the code is finding the last row and pasting data but I need it to be last row + 1.

I'm pasting the data in to two columns for each destination table.
This worked but now getting an error on
ccRecon.Cells(LastRow, 2).PasteSpecial xlPasteValues

I do have other columns from the source data (ImportNonCCB sheet) to enter on the same rows of the other tables but can't figure how I do this. It's no biggie if not.

Code:
Sub AddImportNonCCB()


' Append data from ImportNonCCB to multiple sheets last empty row of table
' toggle off and on


Dim RGC As Worksheet
Dim ImpNonCCB As Worksheet
Dim ccRecon As Worksheet
Dim copyRange As Range
Dim LastRow As Long


Set RGC = Sheets("RG Clients ")
Set ImpNonCCB = Sheets("ImportNonCCB")
Set ccRecon = Sheets("CC Reconfiguration Data")


Application.ScreenUpdating = False


RGC.Range("B3").ListObject.ShowTotals = False


ImpNonCCB.Range("tblImportNonCCB[[ Client Name]]").Copy


With RGC
     LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
    '.offset(1,0)
End With
    RGC.Cells(LastRow, 2).PasteSpecial xlPasteValues
    RGC.Cells(LastRow, 3).PasteSpecial xlPasteValues
    Application.CutCopyMode = False


RGC.Range("B3").ListObject.ShowTotals = True


With ccRecon
     LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
    '.offset(1,0)
End With
    ccRecon.Cells(LastRow, 2).PasteSpecial xlPasteValues
    ccRecon.Cells(LastRow, 3).PasteSpecial xlPasteValues
    Application.CutCopyMode = False


Application.ScreenUpdating = True


End Sub

any help gratefully received!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi I think I am NEARLY there with this but not working exactly how I need.

At the moment the code is finding the last row and pasting data but I need it to be last row + 1.

I'm pasting the data in to two columns for each destination table.
This worked but now getting an error on
ccRecon.Cells(LastRow, 2).PasteSpecial xlPasteValues

I do have other columns from the source data (ImportNonCCB sheet) to enter on the same rows of the other tables but can't figure how I do this. It's no biggie if not.

Code:
Sub AddImportNonCCB()


' Append data from ImportNonCCB to multiple sheets last empty row of table
' toggle off and on


Dim RGC As Worksheet
Dim ImpNonCCB As Worksheet
Dim ccRecon As Worksheet
Dim copyRange As Range
Dim LastRow As Long


Set RGC = Sheets("RG Clients ")
Set ImpNonCCB = Sheets("ImportNonCCB")
Set ccRecon = Sheets("CC Reconfiguration Data")


Application.ScreenUpdating = False


RGC.Range("B3").ListObject.ShowTotals = False


ImpNonCCB.Range("tblImportNonCCB[[ Client Name]]").Copy


With RGC
     LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
    '.offset(1,0)
End With
    RGC.Cells(LastRow, 2).PasteSpecial xlPasteValues
    RGC.Cells(LastRow, 3).PasteSpecial xlPasteValues
    Application.CutCopyMode = False


RGC.Range("B3").ListObject.ShowTotals = True


With ccRecon
     LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
    '.offset(1,0)
End With
    ccRecon.Cells(LastRow, 2).PasteSpecial xlPasteValues
    ccRecon.Cells(LastRow, 3).PasteSpecial xlPasteValues
    Application.CutCopyMode = False


Application.ScreenUpdating = True


End Sub

any help gratefully received!


OK - I figured out how to add last row +1 :)

Only issue is when it's copying to the next sheet I am getting an error?
'this piece is erroring?
ccRecon.Cells(LastRow + 1, 2).PasteSpecial xlPasteValues
ccRecon.Cells(LastRow + 1, 3).PasteSpecial xlPasteValues
Application.CutCopyMode = False

Any ideas please?

Code:
Sub AddImportNonCCB()


' Append data from ImportNonCCB to multiple sheets last empty row of table
' toggle off and on


Dim RGC As Worksheet
Dim ImpNonCCB As Worksheet
Dim ccRecon As Worksheet
Dim copyRange As Range
Dim LastRow As Long


Set RGC = Sheets("HRG Clients ")
Set ImpNonCCB = Sheets("ImportNonCCB")
Set ccRecon = Sheets("CC Reconfiguration Data")


Application.ScreenUpdating = False


RGC.Range("B3").ListObject.ShowTotals = False


ImpNonCCB.Range("tblImportNonCCB[[ Client Name]]").Copy


With RGC
     LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
    
End With
    RGC.Cells(LastRow + 1, 2).PasteSpecial xlPasteValues
    RGC.Cells(LastRow + 1, 3).PasteSpecial xlPasteValues
    Application.CutCopyMode = False


RGC.Range("B3").ListObject.ShowTotals = True


With ccRecon
     LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
End With

'this piece is erroring?    
    ccRecon.Cells(LastRow + 1, 2).PasteSpecial xlPasteValues
    ccRecon.Cells(LastRow + 1, 3).PasteSpecial xlPasteValues
    Application.CutCopyMode = False




Application.ScreenUpdating = True


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top