Format Multiple Textboxes with One Code

reberryjr

Active Member
Joined
Mar 16, 2017
Messages
499
Office Version
  1. 2013
Platform
  1. Windows
I have several textboxes that I want to format as currency, and several others that I want to format as date (MM/DD/YY). When I say format, I'm referring to displaying the desired format in the textboxes themselves. I realize that I can format the textboxes individually, but I'm curious if there's a way to format multiple textboxes in one code set. I've looked online and I'm not seeing anything that says you can, but I'm not sure that is accurate. It seems like there would be a way. Maybe something in the Initialization of a UserForm that says IF Control = X or Y or Z THEN FORMAT as "$#,##0.##"?
 

Some videos you may like

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,224
Depends on how many you mean by "several". If you have 1 to maybe up to 5 or so, and you will always have those particular textboxes meant for the same format, then doing them individually using the Change event is practical. If you have a dozen or a hundred, then a class module would be the way to go; plenty of examples on the web (including this site) for class modules.
 

reberryjr

Active Member
Joined
Mar 16, 2017
Messages
499
Office Version
  1. 2013
Platform
  1. Windows
Class Modules...hmmm....I haven't had the opportunity to experiment with those yet. I'll look into them. Thank you!!
 

Watch MrExcel Video

Forum statistics

Threads
1,122,914
Messages
5,598,840
Members
414,261
Latest member
KatieBsc

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
Top