Hello,
I am new to writing macros and am looking for some help. I have a sheet "main" and a sheet "backup" . I need to search all of the columns for the word "call". When the word call is found, i would like that entire row to be copied to "backup".
Hello,
I am new to writing macros and am looking for some help. I have a sheet "main" and a sheet "backup" . I need to search all of the columns for the word "call". When the word call is found, i would like that entire row to be copied to "backup".
Re: Macros, Copy, Paste, Condition
Hi and welcome to the forum.
How about something like this:
Sub Find_Call()
Dim wsMain As Worksheet, wsBackup As Worksheet
Dim rngCell As Range, strFirst As String
Set wsMain = ThisWorkbook.Worksheets("main")
Set wsBackup = ThisWorkbook.Worksheets("backup")
'the worksheets
With wsMain.Cells
Set rngCell = .Find(what:="call", LookIn:=xlValues)
'look for target text
If Not rngCell Is Nothing Then
'if found, proceed with copying
strFirst = rngCell.Address
Do
rngCell.EntireRow.Copy _
wsBackup.Range("A" & wsBackup.Cells(wsBackup.Rows.Count, "A").End(xlUp).Row + 1)
Set rngCell = .FindNext(rngCell)
Loop While Not rngCell Is Nothing And rngCell.Address <> strFirst
End If
End With
End Sub
Display More
If you are new to VBA then a good tip is to try using the macro recorder to record the process that you want to code. It won't be exactly what you want but it is often a good starting point.
Don’t have an account yet? Register yourself now and be a part of our community!