Copy from one table and append to another if:

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,342
Office Version
  1. 365
Platform
  1. Windows
I have two tables.

One is a list on tab "PBoMsTasks" / PBoMTaskListTable_2
The other is on tab "3 Enter PBoM" / EnterPBoMs

I need to take the data from EnterPBoMs (which headers are in C5:J5) and copy the data from that table and Paste it to the bottom of a third table CMCS_Table on "CMCS.
CMCS headers start in B15 But I need the data pasted into column D not column B of the CMCS

But copy and paste it to the bottom each time there is a value in PBoMTaskListTable_2 row A. each time there is a value in A of the PBoMTaskListTable_2 I need that value and the value in B also copied and pasted along side the data in column B&C of CMCS. Yes it will be the same value down the same number of rows as the number of rows coming from EnterPBoMs.

So this copy and pasting will be repeated the number of times that there are rows in PBoMTaskListTable_2

But I want to the code to first check the value coming from PBoMTaskListTable_2 column A to see if its already in the CMCS table. If it is, I need to delete that data first.

A bit complicated, but hope its clear.

Any help with this complicate code is greatly appreciated.

Thanks
Greg

But I before it does the Copy and Pastes I need it to first check the value in column
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
I still trying to get this to work with no luck.

I want to Loop through table PBoMTaskListTable

For each Row in PBoMTaskListTable I wan to copy table EnterPBoMs and paste it to the bottom of sheet17

Sheet18.ListObjects("EnterPBoMs").DataBodyRange.Copy Sheet17.Range("D" & LastR)

Then I want to Paste the value from PBoMTaskListTable in the same rows I just pasted EnterPBoMs

So if my first table has three rows - I want to take table EnterPBoMs paste it to the bottom of Sheet17 and I want to paste the value from row 1 of my first table down column A

I want to loop through the number of rows I have in fist table.

I just cannot get there on my own.

this doesnt work - it does copy the EnterPBoMs and paste it to the bottom. But thats all this code is doing correctly

Code:
Sub MovePBoM()

Dim lRow As Long, i As Long, iRow
Dim LastR As Long

lRow = Worksheets("PBoMTaskList").Cells(Rows.Count, "B").End(xlUp).Row
LastR = Sheet17.Cells(Rows.Count, "D").End(xlUp).Row + 1
LastRb = Sheet17.Cells(Rows.Count, "B").End(xlUp).Row + 1



iRow = 1

    For i = 1 To lRow
  
    If Cells(i, "B") <> "" Then
    
    Sheet18.ListObjects("EnterPBoMs").DataBodyRange.Copy Sheet17.Range("D" & LastR)
    Sheet17.Range("B" & LastR) = Cells(i, "B").Value
    
    
        iRow = iRow + 1
    Else
  
    End If
    
Next i



End Sub
 
Upvote 0

Forum statistics

Threads
1,215,756
Messages
6,126,692
Members
449,330
Latest member
ThatGuyCap

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