Hello,
I'm new to VB, so any pointers (beyond my specific question) are certainly appreciated. I need to:
[1] compare (row) ranges across two columns with an unequal number of rows (column A [number] to column C [number])
[2] save each result of [1] where there was a match in column B
[3] for each row where there was a match (now stored in B), compare the value from the same row in column D (date) with the same row of column F (date), and store the result in column E
[4] count and message box the final number of matches from column E
Data Example:
A B C D E F
----- ----- ----- ----- ----- -----
12345 match 12345 11/1/2011 match 11/1/2011
77777 34345 ... ...
A and C numbers match, so check same row date in D that does match date in E, place "match" in E, then count and display.
Sub other()
Dim range1, range2, range3, range4, range5, range6 As range
Dim x As Variant, y As Variant, z As Variant, a As Variant
Set range1 = range("A2:A4331")
Set range2 = range("B2:B4331")
Set range3 = range("C2:C1012")
Set range4 = range("D2:D4331")
Set range5 = range("E2:E4331")
Set range6 = range("F2:F1012")
For Each x In range1
For Each y In range3
If x = y Then x.Offset(0, 1) = "match"
Next y
Next x
' this completes step [2], but not sure how to code step [3]
???
c = Application.WorksheetFunction.CountA(range5)
MsgBox "Matches: " & (c)
End Sub
Thank you for any help!
I'm new to VB, so any pointers (beyond my specific question) are certainly appreciated. I need to:
[1] compare (row) ranges across two columns with an unequal number of rows (column A [number] to column C [number])
[2] save each result of [1] where there was a match in column B
[3] for each row where there was a match (now stored in B), compare the value from the same row in column D (date) with the same row of column F (date), and store the result in column E
[4] count and message box the final number of matches from column E
Data Example:
A B C D E F
----- ----- ----- ----- ----- -----
12345 match 12345 11/1/2011 match 11/1/2011
77777 34345 ... ...
A and C numbers match, so check same row date in D that does match date in E, place "match" in E, then count and display.
Sub other()
Dim range1, range2, range3, range4, range5, range6 As range
Dim x As Variant, y As Variant, z As Variant, a As Variant
Set range1 = range("A2:A4331")
Set range2 = range("B2:B4331")
Set range3 = range("C2:C1012")
Set range4 = range("D2:D4331")
Set range5 = range("E2:E4331")
Set range6 = range("F2:F1012")
For Each x In range1
For Each y In range3
If x = y Then x.Offset(0, 1) = "match"
Next y
Next x
' this completes step [2], but not sure how to code step [3]
???
c = Application.WorksheetFunction.CountA(range5)
MsgBox "Matches: " & (c)
End Sub
Thank you for any help!