Hello absoute beginner at VBA!
I have a spreadsheet where I would like to copy data from tabs ATPMD, STPPMD, and SBMD to tab Core, I would like the code to copy in row data where the column name matches on the above tabs.
Thank you so much
Hello absoute beginner at VBA!
I have a spreadsheet where I would like to copy data from tabs ATPMD, STPPMD, and SBMD to tab Core, I would like the code to copy in row data where the column name matches on the above tabs.
Thank you so much
I'm not understanding the requirements. Could you give some examples of which data should be copied and the logic. I don't see any columns with the same names as the sheet names for the three sheets. Please clarify.
Alan עַם יִשְׂרָאֵל חַי
Change an Ugly Report with Power Query
Database Normalization
Complete Guide to Power Query
Man's Mind Stretched to New Dimensions Never Returns to Its Original Form
Thanks for responding Alan
Basically where say Material exists in STPPMD I would like to copy row data as below
113358
113447
602186
1002672
1004127
To be copied under material in core, and also where material decription is found, it's data to be copied and so on.
Many thanks
Hi Alan,
I hope my explanation helped!
Steve
Alan
Firstly thank you so much for your time, I ran the code, it ran and left me on tab SBMD but no data was in Core, maybe I am doing something wrong, I received a message saying it was complete but no data.
Thanks again.
Steve
Steve:
Give this a try:
![]()
Sub Core() Dim w1 As Worksheet Dim w2 As Worksheet Dim w3 As Worksheet Dim w4 As Worksheet Set w1 = Sheets("STPPMD") Set w2 = Sheets("ATPMD") Set w3 = Sheets("SBMD") Set w4 = Sheets("Core") Dim lr1 As Long lr1 = w1.Range("B" & Rows.Count).End(xlUp).Row Dim lr2 As Long lr2 = w2.Range("B" & Rows.Count).End(xlUp).Row Dim lr3 As Long lr3 = w3.Range("B" & Rows.Count).End(xlUp).Row Dim lr4 As Long Dim i As Long Application.ScreenUpdating = False w1.Activate For i = 2 To lr1 w1.Activate lr4 = w4.Range("C" & Rows.Count).End(xlUp).Row If Range("B" & i) <> "" Then Range("B" & i & ":C" & i).Copy w4.Activate w4.Range("C" & lr4 + 1).Select Selection.PasteSpecial Paste:=xlPasteValues End If Next i Application.CutCopyMode = False w2.Activate For i = 2 To lr2 w2.Activate lr4 = w4.Range("C" & Rows.Count).End(xlUp).Row If Range("F" & i) <> "" Then Range("F" & i & ":G" & i).Copy w4.Activate w4.Range("C" & lr4 + 1).Select Selection.PasteSpecial Paste:=xlPasteValues End If Next i Application.CutCopyMode = False w3.Activate For i = 2 To lr3 w3.Activate lr4 = w4.Range("C" & Rows.Count).End(xlUp).Row If Range("E" & i) <> "" Then Range("E" & i & ":F" & i).Copy w4.Activate w4.Range("C" & lr4 + 1).Select Selection.PasteSpecial Paste:=xlPasteValues End If Next i Application.CutCopyMode = False Application.ScreenUpdating = True MsgBox ("Completed") End Sub
Attached is my copy of your workbook with my code. It worked for me. Scroll down the Core page. I wonder if you have some data in that page that makes the last row be something other than row 2.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks