Hello all,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com
ffice
ffice" /><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


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


Right now all I got is this macro that searches for the header and copies the whole column into a new sheet. <o


Sub CopyColumns()<o


Dim i, LastCol<o


LastCol = Range("IV1").End(xlToLeft).Column<o


For i = 1 To LastCol<o


If UCase(Cells(1, i).Value) = "STATUS" Then<o


Cells(1, i).EntireColumn.Copy Destination:= _<o


Sheets("Sheet2").Range("A1")<o


End If<o


<o


If UCase(Cells(1, i).Value) = "COMPANY" Then<o


Cells(1, i).EntireColumn.Copy Destination:= _<o


Sheets("Sheet2").Range("B1")<o


End If<o


Next<o


End Sub<o


<o


Any help will be appreciated!<o


Best regards.<o


Aaron.<o

