String matches required Format in VBA

psycoperl

Active Member
Joined
Oct 23, 2007
Messages
339
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
  3. Web
I have an inputbox that a user is entering information as part of a VBA Sub.

I want the user to enter their Activity Code(s) which are in the format of ZZZZ.000 is there a way to check if the format of the string matches the required format? Where Z is any letter A-Z and 0 is any digit.

Thanks
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Instead of having them enter data using an InputBox, why not use a Form?

If you do that, you can use an Input Mask of LLLL.000, which will do what you want.

Otherwise, you may need to write some VBA to validate the entry.
 
Upvote 0
I agree with Joe4 recommendation to use a form.

I over 15+ years of doing Access development I have used the input box maybe once or twice. Since it does not allow any data validation, etc. I just find it not very user friendly.

I would use a form to display a list of the available codes. If picking a single code you could use a combo box. If selecting multiple codes I use a listbox or a sub form.
 
Upvote 0

Forum statistics

Threads
1,224,568
Messages
6,179,600
Members
452,927
Latest member
whitfieldcraig

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