VBA - Wildcard not working in string search

RockandGrohl

Well-known Member
Joined
Aug 1, 2018
Messages
794
Office Version
  1. 365
Platform
  1. Windows
Hello, thought the below would work but it skips over applicable lines

VBA Code:
Do Until Cells(ActiveCell.Row, "A").Value = "" Or Cells(ActiveCell.Row, "A").Value = tourno & "-H*"


Say the tourno variable is "ABC123", we have lines that are "ABC123-H01" and "ABC123-H02"

These lines are skipped over, but they should be applicable. If I change the criteria to "tourno & "-H01" for instance, it works perfectly.


What I'm trying to do is take a 6-digit variable, and then find all the strings where the 6-digit variable has a H-number string after it (whether it be -H01, -H02 etc)

Cheers.
 

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.
Fixed it by doing the traditional filter then copy visible cells:

VBA Code:
ActiveSheet.Range("$A$1:$AF$" & lastrow).AutoFilter field:=1, Criteria1:=tourno & "*"
ActiveSheet.Range("$A$1:$AF$" & lastrow).AutoFilter field:=2, Criteria1:="Hotel Option"

If Not Range("A2:A" & lastrow).SpecialCells(xlCellTypeVisible).Count > 1 Then
ActiveSheet.ShowAllData
Else
Range("A3:AF" & lastrow).SpecialCells(xlCellTypeVisible).Copy
tr.Activate
tr.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteAll
Range("A" & currow).Activate
End If
 
Upvote 0

Forum statistics

Threads
1,218,235
Messages
6,141,315
Members
450,347
Latest member
Santoli3

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