had1015
11-15-2016, 10:31 AM
Hi,
I would like assistance with getting this code to work. It is not populating column AI with the correct data:
Sub A_New_Compare()
Dim i, j As Long
Dim StartTime As Double
Dim MinutesElapsed As String
'Remember time when macro starts
StartTime = Timer
With Worksheets("BASELINE_7NOV16")
For i = 2 To .Cells(.Rows.Count, "F").End(xlUp).Row
If Application.CountIf(Worksheets("BASELINE_14NOV16").Range("G:G"), .Cells(i, "G")) > 0 Then
With Worksheets("BASELINE_7NOV16")
For j = 2 To .Cells(.Rows.Count, "D").End(xlUp).Row
If Application.CountIf(Worksheets("BASELINE_14NOV16").Range("D:D"), .Cells(i, "D")) < 1 Then
.Cells(i, "AI").Value = Worksheets("BASELINE_14NOV16").Cells(i, "D").Value
End If
Next j
End With
Else
' .Cells(i, "U").Value = ""
End If
Next i
End With
'Determine how many seconds code took to run
MinutesElapsed = Format((Timer - StartTime) / 86400, "hh:mm:ss")
'Notify user in seconds
MsgBox "This code ran successfully in " & MinutesElapsed & " minutes", vbInformation
End Sub
Any help would be greatly appreciated.
I would like assistance with getting this code to work. It is not populating column AI with the correct data:
Sub A_New_Compare()
Dim i, j As Long
Dim StartTime As Double
Dim MinutesElapsed As String
'Remember time when macro starts
StartTime = Timer
With Worksheets("BASELINE_7NOV16")
For i = 2 To .Cells(.Rows.Count, "F").End(xlUp).Row
If Application.CountIf(Worksheets("BASELINE_14NOV16").Range("G:G"), .Cells(i, "G")) > 0 Then
With Worksheets("BASELINE_7NOV16")
For j = 2 To .Cells(.Rows.Count, "D").End(xlUp).Row
If Application.CountIf(Worksheets("BASELINE_14NOV16").Range("D:D"), .Cells(i, "D")) < 1 Then
.Cells(i, "AI").Value = Worksheets("BASELINE_14NOV16").Cells(i, "D").Value
End If
Next j
End With
Else
' .Cells(i, "U").Value = ""
End If
Next i
End With
'Determine how many seconds code took to run
MinutesElapsed = Format((Timer - StartTime) / 86400, "hh:mm:ss")
'Notify user in seconds
MsgBox "This code ran successfully in " & MinutesElapsed & " minutes", vbInformation
End Sub
Any help would be greatly appreciated.