How do I format an Excel form control from an array in a single statement ?

Hi,

I'm populating an Excel user form control (a textbox) from an array and then formatting the control in the next statement. Is there any way to combine these two operations into a single VBA statement. I've tried, unsuccessfully.

Me.Controls("teBasicFee" & i).Value = EnquiryItemsArray(x, 13)
Me.Controls("teBasicFee" & i).Value = Format(Me.Controls("teBasicFee" & i).Value, "#,##0.00")

Thanks
Toco
TocogroupAsked:
Who is Participating?
 
Rgonzo1971Connect With a Mentor Commented:
Hi,

pls try

Me.Controls("teBasicFee" & i).Value = Format(EnquiryItemsArray(x, 13), "#,##0.00")

Open in new window

Regards
0
 
andrew_manCommented:
with Me.Controls("teBasicFee" & i)
.Value = EnquiryItemsArray(x, 13)
.Value = Format(Me.Controls("teBasicFee" & i).Value, "#,##0.00")
End With
0
 
TocogroupAuthor Commented:
Well actually I was trying to reduce the code rather than increase it. I've got a large number of controls to format and I was wanting to cut down on the coding.
0
 
TocogroupAuthor Commented:
Yes, that's it thanks. I thought i'd tried that but I must have got the syntax wrong. Thanks for your quick reply.
0
All Courses

From novice to tech pro — start learning today.