Hi. I need a code snippet to make the attached code check two cells on a row and paste the data into them if they are empty. If they are not empty, the original code should take over until next i.
I've uploaded a file with hopefully not too much detail. I would really appreciate it if you would take a look at it.
The above is the most important thing, but...
PS: I don't know if this should be a separate thread, so please let me know if it should: After the macro runs all the way through, it clears ALL of the data in column V instead of only clearing the data that was actually posted to the other location. I can work around that, but if there's a way to make it leave the unused data, that would awesome. Thanks!
Option Explicit
Sub AddDatesAmounts()
Dim ObjDic As Object
Set ObjDic = CreateObject("Scripting.Dictionary")
Dim LR As Long
Dim I As Long
Dim WkDate As Date
Const FR As Integer = 4 ' First Row of data
Dim Temp
Application.ScreenUpdating = False
WkDate = Range("V1")
With ObjDic
LR = Range("U" & Rows.Count).End(3).Row
For I = FR To LR
If (Cells(I, "V") <> "") Then .Item(Cells(I, "U").Value & "/" & Cells(I, "V").Value) = Cells(I, "V").Value
Next
LR = Range("B" & Rows.Count).End(3).Row
For I = FR To LR
If (Cells(I, "P") <> "") Then
Temp = Cells(I, "B").Value & "/" & Cells(I, "P").Value
If (.exists(Temp)) Then
If ((Cells(I, "L") = "") And (Cells(I, "M") = "")) Then
Cells(I, "L") = Format$(WkDate, "mm/dd/yy")
Cells(I, "M") = Cells(I, "P")
.Item(Temp) = ""
End If
End If
End If
Next I
LR = Range("U" & Rows.Count).End(3).Row
For I = FR To LR
If (Cells(I, "V") <> "") Then
Temp = Cells(I, "U").Value & "/" & Cells(I, "V").Value
'clears ALL amounts in "V"
If (.exists(Temp)) Then Cells(I, "V") = ""
End If
Next
End With
Application.ScreenUpdating = True
End Sub
Bookmarks