Code Failing To Get Me Result When I Use Number Criteria Instead Of String

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
Code:
Private Sub ComboBox1_Click()
   Dim Lst As Variant
   Dim db As Worksheet
   Dim i As Long

   Set db = Sheets("Sheet1")
   With db.Range("B4", db.Range("B" & Rows.Count).End(xlUp))
      Lst = Filter(db.Evaluate("transpose(if(" & .Offset(, 1).Address & "=" & Chr(34) & Me.ComboBox1.Value & Chr(34) & "," & .Address & ",""#""))"), "#", False)
   End With
   
   Me.ComboBox2.List = Lst
End Sub

This code was written by @Fluff and has been running smoothly until I tried it with numbers instead of the usual string.
Instead of the X, Y, Z criteria I was using before, I am now using 1, 2, 3 criteria but the code is not able to load the data into combobox2.
Can someone please fix that for me?

Thanks in advance.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
You need to use
VBA Code:
      Lst = Filter(db.Evaluate("transpose(if(" & .Offset(, 1).Address & "=" & Me.ComboBox1.Value & "," & .Address & ",""#""))"), "#", False)
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,393
Members
449,446
Latest member
CodeCybear

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