Format Multiple Textboxes with One Code

reberryjr

Well-known Member
Joined
Mar 16, 2017
Messages
714
Office Version
  1. 365
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.##"?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
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.
 
Upvote 0
Class Modules...hmmm....I haven't had the opportunity to experiment with those yet. I'll look into them. Thank you!!
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,326
Members
452,635
Latest member
laura12345

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