VBA Userform, Make all label boxes format as Zip Codes

amxtomzo

Active Member
Joined
Nov 7, 2009
Messages
312
Hello and thanks for looking

I will have about 40 label boxes that are linking from a worksheet,
the info coming into these label boxes are zip codes

the label boxes are named as Lb3 to Lb40
and I would like them to format as 5 digit Zip Codes

I was thinking of putting something like this in Initialized
but I am missing something, I keep getting error messages

Code:
For j = 3 To 40
    With UFZipAssigned.Controls("Lb" & j)
        .Caption = Format(("Lb" & j), Value, "00000")
        
    End With
Next j

thank you

Thomas
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try this.
Code:
For j = 3 To 40
    With UFZipAssigned.Controls("Lb" & j)
        .Caption = Format(.Caption, Value, "00000")
        
    End With
Next j
 
Last edited:
Upvote 0
Norie

No Luck
comes back with error cant find specified object

right now there are only 2 pieces of code in Initialize
One that links the cells I want to list
and this one I am trying to create

Thomas
 
Upvote 0
Try this.
Rich (BB code):
For j = 3 To 40
    With UFZipAssigned.Controls("Lb" & j)
        .Caption = Format(.Caption, Value, "00000")
    End With
Next j
Norie

No Luck
comes back with error cant find specified object
I know you copied what the OP had, but the Format function only takes two arguments when used the way the OP wants... I am not sure what "Value" is supposed to be doing in there, but I suspect if you remove it, your code will function properly...
Rich (BB code):
For j = 3 To 40
    With UFZipAssigned.Controls("Lb" & j)
        .Caption = Format(.Caption, "00000")
    End With
Next j
 
Last edited:
Upvote 0
Rick

Bingo, that did it, working now

thank you Again Rick

Norie

Thank you as well

I do greatly appreciate the support I find here

Thomas
 
Upvote 0

Forum statistics

Threads
1,223,744
Messages
6,174,252
Members
452,553
Latest member
red83

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