This is test code that demonstrates what I need to do. It looks for an "M" and when found, copies and pastes the 2 cells adjacent.
I need the code to IMMEDIATELY erase the "M" once it is done. I can't seem to make that happen. Any help appreciated.
I need the code to IMMEDIATELY erase the "M" once it is done. I can't seem to make that happen. Any help appreciated.
VBA Code:
Sub Find()
Application.ScreenUpdating = False
Dim SearchRange As Range
Dim FindCell As Range
Dim Check As Boolean
Dim LastRow As Long
Dim ws As Worksheet
Dim ws2 As Worksheet
Dim FindCounter As Long
Set ws = Worksheets("Sheet1")
Set ws2 = Worksheets("Sheet2")
Sheets("Sheet1").Select
LastRow = ws.Cells(Rows.Count, "F").End(xlUp).Row
Set SearchRange = Range("F1:F" & LastRow)
FindCounter = 0
ws2.Range("H10:I30").Clear
For Each FindCell In SearchRange
If FindCell.Value = "M" Then
FindCounter = FindCounter + 1
FindCell.Offset(0, 1).Resize(, 2).Copy
ws2.Range("H10").Insert
Application.CutCopyMode = False
End If
Next
MsgBox "Succes!" & vbNewLine & vbNewLine & "This many cells were found: " & FindCounter
Application.ScreenUpdating = True
Sheets("Sheet2").Select
End Sub