0
votes

" find " cell value in header will keep changing in raw file, i need " find " cell value ENTIRE column should copy and paste in sheet2

Sub Macro3()

Cells.Find(What:="FSP Center", After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate`
Cells.FindNext(After:=ActiveCell).Activate`
Columns("A:A").Select 'i want to select entire column 
Selection.Copy
Sheets("Sheet2").Select
ActiveSheet.Paste

End Sub

1

1 Answers

1
votes
Sub Macro3()
    
    Dim f As Range
    Set f = Rows(1).Find(What:="FSP Center", After:=ActiveCell, _
                       LookIn:=xlFormulas, LookAt:=xlPart, _
        SearchOrder:=xlByRows, SearchDirection:=xlNext)

    If Not f Is Nothing Then
        f.EntireColumn.Copy Sheets("Sheet2").Range("A1")
    End If

End Sub

'fixed the misspelling "If"