简体   繁体   中英

vba Entire Column should copy

" 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

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 f

End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM