Hi, I'm looking to pull a date (call it D1) from 1 tab, and look it up with the match function (yes, must be the match function because there are other criteria involved). Problem is, the date i am looking up can be Any day of the year, but the table i am looking it up in (call it D2), is only end of month, quarters. (3/31/2017, 06/30/2017, 09/30/2017, 12/31/2017)
Here is what I have:
D1 = Worksheets("Sheet1").Cells(y, 27)
row = Find(Postal, Type1, D1) 'as you can see here, postal and type are the other criteria i am looking for
'Here cVal = D1 and c = D2 column (and yes, this find function isn't mine, got it from a thread on here)
Function Find(aVal As String, bVal As String, cVal) As Long
Dim maxRow As Long
Dim row As Long
maxRow = Range("A100000").End(xlUp).row
For row = 3 To maxRow
Dim a As String
a = ActiveSheet.Cells(row, 3).Value
b = ActiveSheet.Cells(row, 4).Value
c = ActiveSheet.Cells(row, 5).Value
If a = aVal And b = bVal And c = cVal Then
Find = row
Exit Function
End If
Next row
Find = -1
End Function
Also please note.... that my code runs through this thousands of time and is very time consuming, given the size of the database. Any suggestions that would make this faster would be greatly appreciated! (end goal is to name criteria (looping from 1-3000) on 1 tab, then look it up on another tab (1 at a time)) and result is a number that is offset from the matched numbers.
Here is what I have:
D1 = Worksheets("Sheet1").Cells(y, 27)
row = Find(Postal, Type1, D1) 'as you can see here, postal and type are the other criteria i am looking for
'Here cVal = D1 and c = D2 column (and yes, this find function isn't mine, got it from a thread on here)
Function Find(aVal As String, bVal As String, cVal) As Long
Dim maxRow As Long
Dim row As Long
maxRow = Range("A100000").End(xlUp).row
For row = 3 To maxRow
Dim a As String
a = ActiveSheet.Cells(row, 3).Value
b = ActiveSheet.Cells(row, 4).Value
c = ActiveSheet.Cells(row, 5).Value
If a = aVal And b = bVal And c = cVal Then
Find = row
Exit Function
End If
Next row
Find = -1
End Function
Also please note.... that my code runs through this thousands of time and is very time consuming, given the size of the database. Any suggestions that would make this faster would be greatly appreciated! (end goal is to name criteria (looping from 1-3000) on 1 tab, then look it up on another tab (1 at a time)) and result is a number that is offset from the matched numbers.