Solved

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

Posted on 2013-12-03
4
158 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 48

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now