Excel VBA Update: Find data, loop through multiple worksheets, copy range

前端 未结 2 1830
迷失自我
迷失自我 2021-01-22 20:39

Update to this thread from yesterday: Excel VBA: Find data, loop through multiple worksheets, copy specific range of cells

(Special thanks to findwindow for getting me t

2条回答
  •  不知归路
    2021-01-22 21:16

    Not sure if this is what you are looking for? There was an end if missing? You can do the copy in a single line. See below ...

    For Each ws In X.Worksheets
        With ws.Range("A:A")
            Set rng = .Find(What:=A, After:=ActiveCell, LookIn:=xlValues, _
            LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
            If rng Is Nothing Then 'do nothing
              Else
              fRow = rng.Row
               ws.Range("A" + CStr(fRow) + ":" + "R" + CStr(fRow)).Copy Destination:=Destination
            End If
        End With
    Next ws
    

提交回复
热议问题