Solved

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

Posted on 2013-12-03
4
193 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 51

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

710 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