worksheet merge /append 911

Hammertime

New Member
Joined
Feb 13, 2009
Messages
4
Good afternoon!
Long time listener, first time caller...or something like that.
I have exported 2 CSV files from an oddball custom database, and cleaned up the data. There is a uniqueID (part#) between the 2 and aside from that all is different. What i'd like to do is find an easy way to create a 3rd worksheet, that will bring in the data from the first (26,000 lines by 18 columns) and append the data from the second (24,000 lines by 10 columns).
The ONLY common columns will be the PART#.
As you can see by the number of lines, some items are not listed in the second (making a simple copy and paste unusable).
Also, if there IS an item in the second that is NOT listed in the first, then a new line will need to created, with ONLY the applicable info populated into it.
i have attached 3 images to demo the bulk of what i am thinking...

secondr.jpg


firstef.jpg


and the finished product:
newz.jpg


any help or suggestions would be HUGELY appreciated.
thanks!

Damien
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi Damien

Could you not use VLOOKUP to achieve your results?
 
Upvote 0
I may have neglected to mention my level of Newb-ness. i am looking into that as we speak!!

Thanks Dave.

D'
 
Upvote 0
I would do it as a macro something like this:
Sub MergeFile()
Dim Part(10)

For x = 1 To 24000
Windows("File2.xls").Activate
For y = 1 To 10
Part(y) = Cells(x, y).Value
Next y
w = 2
z = 19
Found = 0
Windows("File1.xls").Activate
Do Until IsEmpty(Cells(w, 1).Value)
If Part(1) = Cells(w, 1).Value Then
For y = 2 To 10
Cells(w, z).Value = Part(y)
z = z + 1
Found = 1
Exit Do
Next y
Else
w = w + 1
End If
Loop
If Found = 0 Then
NotBlank = 0
For Each cell In Selection
If cell.Value <> "" Then NotBlank = NotBlank + 1
Next cell
newRow = NotBlank + 1
z = 19
Cells(newRow, 1).Value = Part(1)
For y = 2 To 10
Cells(newRow, z).Value = Part(y)
z = z + 1
Next y
End If
Next x
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,065
Messages
6,122,944
Members
449,095
Latest member
nmaske

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