Hi, I have a couple of sheets that I need to compare column header names and append column content from sheet1 to sheet2 where there is a match.
I Googled this 'cause I wasn't sure how to do it and found this code:
The line
Is throwing the 1004 error, any ideas how I can resolve this?
Thanks for any help
I Googled this 'cause I wasn't sure how to do it and found this code:
Code:
Sub VBAX_SamT()
'Adjust 2 instances "video-eng" to suit
'For each header in Master Sheet, searches all other sheets for matching header,
'Then copys all data below matching header to bottom of Used Master header column.
Dim rngMasterHeaders As Range
Dim Cel As Range
Dim Sht As Worksheet
Dim CopyHeader As Range
Dim Dest As Range
Set rngMasterHeaders = Sheets("video-eng"). _
Range(Cells(1, "A"), Cells(1, Columns.Count).End(xlToLeft))
For Each Cel In rngMasterHeaders
If Cel.value <> "" Then
For Each Sht In Worksheets
If Sht.name <> "video-eng" Then
Set CopyHeader = Sht.Range("1:1").Find(Cel.value)
If Not CopyHeader Is Nothing Then
Set Dest = Cel.Parent.Range(Rows.Count, Cel.Column).End(xlUp).Offset(1)
Range(CopyHeader.Offset(1), Cells(Rows.Count, CopyHeader.Column).End(xlUp)).Copy Dest
Set CopyHeader = Nothing
End If
End If
Next Sht
End If
Next Cel
End Sub
The line
Code:
Set Dest = Cel.Parent.Range(Rows.Count, Cel.Column).End(xlUp).Offset(1)
Thanks for any help