VBA to Copy Specifc Rows if Matching Criteria is Met

Tirrell, Eric 1 Reputation point
2022-04-18T13:56:59.877+00:00

Hey All,

I am very new to VBA and I'm working on Macro and can't seem to make it work. I am trying to write one to copy Rows DB:DJ and EM:EX on sheet 1 to rows AM:BG on Sheet 2 as long as Column L in sheet 1 matches Column M in sheet 2. What I have so far is below:

Sub ABC()
Dim s1 As Worksheet, s2 As Worksheet
Set s1 = Sheets("Sheet1")
Set s2 = Sheets("Sheet2")
Dim ir As Long, ir2 As Long
Dim i As Long
ir = s1.Range("L" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
For i = 2 To ir
ir2 = s2.Range("M" & Rows.Count).End(xlUp).Row
If s1.Range("L" & i) = s2.Range("M" & i) Then
s1.Range("L" & "DB11:DJ102" & "EM12:EX102").RowsCount.Copy
s2.Range("M" & "AM2:BG88").PasteSpecial xlPasteValues
End If
Next i
Applications.CutCopyMode = False
Applications.ScreenUpdating = True
MsgBox "Complete"

End Sub

Please let me know if you need additional information. Any help is much appreciated!

0 comments No comments
{count} votes