Hello. I have this code that compares two columns between two sheets. It matches the values in column J in “Ships” with column M in “Main”. It copies the value 10 cells to the right from sheet “Ships” and pastes it in the 3rd cell to the right on “Main” sheet. However, I need it to only paste it if the 3rd cell over of column M is empty. I have tried tweaking it with no luck. Any help is appreciated. Here is my code. Thanks!
So I need it to identify if C1.Offset( ,3).Value is empty
So I need it to identify if C1.Offset( ,3).Value is empty
VBA Code:
Private Sub GetCompletionPercentage()
Dim Cl As Range
Dim Dic As Object
lastRow = Cells(Rows.Count, "P").End(xlUp).Row
Set rng = Range("P2:P" & lastRow)
Set Dic = CreateObject("scripting.dictionary")
With Sheets("Ships")
For Each Cl In .Range("J2", .Range("J" & Rows.Count).End(xlUp))
Dic(Cl.Value) = Cl.Offset(, 10).Value
Next Cl
End With
With Sheets("Main")
For Each Cl In .Range("M2", .Range("M" & Rows.Count).End(xlUp))
If Dic.Exists(Cl.Value) Then Cl.Offset(, 3).Value = Dic(Cl.Value)
Next Cl
End With
End Sub