Convert job numbers to text for wildcard search

jaded62

New Member
Joined
Oct 23, 2023
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hi all.

I am working on a scheduling application which allows the user to search for jobs (there's maybe 2000+ job numbers in the list) by number and name, dump the output to a listbox, from which the user selects the relevant job so they can schedule it.

My problem is the job numbers themselves. In their most basic format the are 4 digit numbers, being the first job we do on a particular site. From these jobs we then over time, do more jobs on the site and these are named as "sub jobs" using _Sxxxx or _Mxxxx. These sub job numbers are text and so are searchable with wildcards.

What I want to do is to convert the 4 digit job numbers to text for searching, then convert them back so they are unchyanged. If I were to do this manually in a sheet I'd insert a ' before each number so Excel regards it as text.

Is there an alternative to the ' preface method above that I can use in VBA?

Cheers.
 

Attachments

  • Capture.PNG
    Capture.PNG
    131.7 KB · Views: 18

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Instead of converting the 4 digit job numbers to text, using VBA, you could use the InStr function.

The general form is InStr([start], string1, string2, [compare]) where string1 would be the 4 digit code and string2 would the seach string. This function will also allow you to use wildcards so you can cover both options.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,260
Members
452,627
Latest member
KitkatToby

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