Hello all,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
I need help with a macro that analyzes the header of all columns and then it searches in each row if for certain data and if it meets the criteria it copies only the specified columns into a new sheet.<o></o>
Right now all I got is this macro that searches for the header and copies the whole column into a new sheet. <o></o>
Sub CopyColumns()<o></o>
Dim i, LastCol<o></o>
LastCol = Range("IV1").End(xlToLeft).Column<o></o>
For i = 1 To LastCol<o></o>
If UCase(Cells(1, i).Value) = "STATUS" Then<o></o>
Cells(1, i).EntireColumn.Copy Destination:= _<o></o>
Sheets("Sheet2").Range("A1")<o></o>
End If<o></o>
<o></o>
If UCase(Cells(1, i).Value) = "COMPANY" Then<o></o>
Cells(1, i).EntireColumn.Copy Destination:= _<o></o>
Sheets("Sheet2").Range("B1")<o></o>
End If<o></o>
Next<o></o>
End Sub<o></o>
<o></o>
Any help will be appreciated!<o></o>
Best regards.<o></o>
Aaron.<o></o>
<o></o>
I need help with a macro that analyzes the header of all columns and then it searches in each row if for certain data and if it meets the criteria it copies only the specified columns into a new sheet.<o></o>
Right now all I got is this macro that searches for the header and copies the whole column into a new sheet. <o></o>
Sub CopyColumns()<o></o>
Dim i, LastCol<o></o>
LastCol = Range("IV1").End(xlToLeft).Column<o></o>
For i = 1 To LastCol<o></o>
If UCase(Cells(1, i).Value) = "STATUS" Then<o></o>
Cells(1, i).EntireColumn.Copy Destination:= _<o></o>
Sheets("Sheet2").Range("A1")<o></o>
End If<o></o>
<o></o>
If UCase(Cells(1, i).Value) = "COMPANY" Then<o></o>
Cells(1, i).EntireColumn.Copy Destination:= _<o></o>
Sheets("Sheet2").Range("B1")<o></o>
End If<o></o>
Next<o></o>
End Sub<o></o>
<o></o>
Any help will be appreciated!<o></o>
Best regards.<o></o>
Aaron.<o></o>