Solved

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

Posted on 2013-12-03
4
178 Views
Last Modified: 2013-12-03
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
0
Comment
Question by:Tocogroup
  • 2
4 Comments
 
LVL 4

Expert Comment

by:andrew_man
ID: 39692300
with Me.Controls("teBasicFee" & i)
.Value = EnquiryItemsArray(x, 13)
.Value = Format(Me.Controls("teBasicFee" & i).Value, "#,##0.00")
End With
0
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39692301
Hi,

pls try

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

Open in new window

Regards
0
 

Author Comment

by:Tocogroup
ID: 39692309
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
 

Author Closing Comment

by:Tocogroup
ID: 39692358
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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question