简体   繁体   中英

VBA Excel Find Text in Column A, copy entire row

Not sure why this is defeating me, but it would seem it is relatively easy. What I am trying to do is ind a string, ie "Game 1" in column A, copy that entire row, and paste that row to sheet2 at A1.

Any direction would be helpful.

I think I got it. I have limited experience with VBA, but that was almost two decades ago, and conditional logic has gotten the better of me. This is what I got at the moment that seems to be working... onyl thing now is to figure out to loop it for "Game 2", "Game 3", etc if they are even there. Thank you all for helping...

 Sub FindText()

' FindText Macro
' find "Game 1" "Game 2" etc

' Keyboard Shortcut: Ctrl+f

Sheets("Input").Select
Columns("A").Select
On Error Resume Next
Selection.Find(What:="Game 1", After:=ActiveCell, LookIn:= _
    xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
    xlNext, MatchCase:=False, SearchFormat:=False).Activate
If Err.number = 91 Then
    MsgBox "There is No Game 1 Loser."
    End
End If

Dim intRow As Integer
intRow = ActiveCell.Row

Rows(intRow & ":" & intRow).Copy

Sheets("Sheet1").Select
Range("A2").Select
ActiveSheet.Paste

Call format
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