humbleguy01
Technical User
Hi,
I've been trying to find out how to do this all night, but the code is still jibberish to me. I need help.
I've got 2 csv files (with thousands of rows, each) with data I need to merge. The 2nd csv just has 2 columns: the record label; and the data value that needs to be copied. The 1st csv has 4 columns, with the first column being the record label. I just want to paste the data value from the 2nd csv to the 5th column of the corresponding record in the 1st csv.
I tried creating a macro where I:
1) copied the record label from the 2nd_CSV
2) made the 2nd_CSV the active one
3) used the Find command, pasted the label into Find Next,
4) moved the active cell over to the 5th column
5) Activated the 2nd_CSV & copied the data value
6) pasted the data value to the 5th column of the 1st_CSV
7) moved the active cell to A1, so the FindNext would work for the next search.
Sub Macro8()
'
' Macro8 Macro
'
' Keyboard Shortcut: Ctrl+j
'
Dim SearchValue As Variant
Windows("2nd_CSV").Activate
SearchValue = Selection.Copy
Windows("1st_CSV").Activate
Cells.Find(What:="SearchValue", After:= _
ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 4).Range("A1").Select
Windows("2nd_CSV").Activate
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("1st_CSV").Activate
ActiveSheet.Paste
ActiveSheet.Range("A1").Select
Windows("2nd_CSV").Activate
ActiveCell.Offset(1, -1).Range("A1").Select
End Sub
I've been trying to find out how to do this all night, but the code is still jibberish to me. I need help.
I've got 2 csv files (with thousands of rows, each) with data I need to merge. The 2nd csv just has 2 columns: the record label; and the data value that needs to be copied. The 1st csv has 4 columns, with the first column being the record label. I just want to paste the data value from the 2nd csv to the 5th column of the corresponding record in the 1st csv.
I tried creating a macro where I:
1) copied the record label from the 2nd_CSV
2) made the 2nd_CSV the active one
3) used the Find command, pasted the label into Find Next,
4) moved the active cell over to the 5th column
5) Activated the 2nd_CSV & copied the data value
6) pasted the data value to the 5th column of the 1st_CSV
7) moved the active cell to A1, so the FindNext would work for the next search.
Sub Macro8()
'
' Macro8 Macro
'
' Keyboard Shortcut: Ctrl+j
'
Dim SearchValue As Variant
Windows("2nd_CSV").Activate
SearchValue = Selection.Copy
Windows("1st_CSV").Activate
Cells.Find(What:="SearchValue", After:= _
ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 4).Range("A1").Select
Windows("2nd_CSV").Activate
ActiveCell.Offset(0, 1).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
Windows("1st_CSV").Activate
ActiveSheet.Paste
ActiveSheet.Range("A1").Select
Windows("2nd_CSV").Activate
ActiveCell.Offset(1, -1).Range("A1").Select
End Sub