Hi, Can you help me add the following to the end of the code below? Note, the code below has a "stopping" point, and an "ending" point. I only want to run the following after the below code completes and ends.....
After completing the code, do this....
Copy ("R17:S17") and paste down (“R:S”) until “V” is has 3 blanks in a row (this is end of data on sheet).
Then, if there is any text in (“A”) greater than row A14, then Selection.ClearContents on ("R:S") on that row, and the row below it.
Example: If ("A15") has any text, then Selection.ClearContents of R15, S15, R16, S16 ---- (R:S is cleared on the same row as "A" and on one row GREATER than that row).
Thanks!
Below is the current code I'm running...
After completing the code, do this....
Copy ("R17:S17") and paste down (“R:S”) until “V” is has 3 blanks in a row (this is end of data on sheet).
Then, if there is any text in (“A”) greater than row A14, then Selection.ClearContents on ("R:S") on that row, and the row below it.
Example: If ("A15") has any text, then Selection.ClearContents of R15, S15, R16, S16 ---- (R:S is cleared on the same row as "A" and on one row GREATER than that row).
Thanks!
Below is the current code I'm running...
Code:
Sub Macro1()
Dim lr As Long
Dim r As Long
Application.ScreenUpdating = True
'Find last row in column J with data
lr = Cells(Rows.Count, "J").End(xlUp).Row
'Loop through all rows starting in row 17
For r = 17 To lr
' If columns J and V are different and column J is not blank
If (Cells(r, "J") <> Cells(r, "V")) And (Cells(r, "J") <> "") Then
' Run code if they do not match
Rows(r).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A" & r & ":S" & r).Delete Shift:=xlUp
Range("J" & r).Copy
Range("V" & r).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("KB" & r).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Else
' If column J is blank and columns A and U are different
If (Cells(r, "J") = "") And (Left(Cells(r, "A"), 5) <> Left(Cells(r, "U"), 5)) Then
' What to do if columns A and U do not match
MsgBox "Columns A and U do not match on row " & r, vbOKOnly, "MACRO STOPPED!!!"
Exit Sub
End If
End If
Next r
Application.ScreenUpdating = False
End Sub