MATCH (or FIND) with multiple criteria and wildcards

Dr. Demento

Well-known Member
Joined
Nov 2, 2010
Messages
618
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I need to find the .address of the cell within a header (rngHeader) that contains either "DoB" or "Birth*" ([Birth* = Birth or Birthdate or Birthday] I'd like the seach/match to be case-insensitive, please).
This works fine but won't capture DoB:
Code:
rngDoB = WorksheetFunction.Match("BIRTH*", rngHeader, 0)
but this doesn't (I tried both "&" and "or" separately)
Code:
rngDoB = WorksheetFunction.Match("BIRTH*" &/or "DoB", rngHeader, 0)
I searched around but couldn't come up with anything that merged both multiple criteria and wildcards. Or, I may be totally spacing it (altogether possible).

Thanks, y'all.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I'm stuck in a circular loop. According to this post, I can assign multiple criteria by referencing the specific cells and concatenating the named range/cell; however, I'm actually searching for the column that contains the search criteria. *head imploding into Mobius strip*

Any pointers out of this wormhole? Again, I'm trying to find the single column in the header that could contain any of the following terms: DoB OR Birthdate OR Birthday OR Date of Birth.

Richard Schollar's avatar seems fitting right about now ;)
 
Last edited:
Upvote 0
In the interest of closing the loop, the good folks at Chandoo had some ideas.

From Deepak (looped searches):
Code:
Option Explicit

Sub test()

Dim frng As Range, rngHeader As Range

Set rngHeader = [A1:D1]
Set frng = rngHeader.Find("BIRTH", , , xlPart, , , True)

If frng Is Nothing Then Set frng = rngHeader.Find("DOB", , , xlPart, , , True)
If Not frng Is Nothing Then Debug.Print frng.Address

End Sub


From jindon:
Code:
Dim x
     x = Filter(Application.IfError(Application.Match(Array("DOB", "*Birth"), rngHeader, 0), Chr(2)), Chr(2), 0)
     If UBound(x) > -1 Then
         Set rngDOB = rngHeader.Cells(x(0))
         MsgBox rngDOB.Address
     Else
         MsgBox "Not found"
     End If
 
Upvote 0

Forum statistics

Threads
1,215,691
Messages
6,126,220
Members
449,303
Latest member
grantrob

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top