Syntax for FormatCurrency

Posted on 2006-07-21
Last Modified: 2012-08-13
This is Excel VBA
I have this piece of code I need to add

FormatCurrency to this line in the code
(TextBox2.Text = rng(.ListIndex + 1, 3)

What would be the proper syntax?

Any help would greatly be appreciated

With ComboBox1
        Set rng = Range(.RowSource)
        TextBox1.Text = rng(.ListIndex + 1, 2)
       (TextBox2.Text = rng(.ListIndex + 1, 3)        
     End With
Question by:ca1358
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
  • 2
LVL 65

Expert Comment

by:Jim Horn
ID: 17155321
In Excel VBA you can use CCur(value) to convert any value to a currency $#,###.## format.

Author Comment

ID: 17156172
Sorry,  I should have told you it is a UserForm.

LVL 23

Accepted Solution

gecko_au2003 earned 500 total points
ID: 17159971
Dim curOne As Currency
Dim curTwo As Currency

For i = LBound(ComboBox1.Count) To UBound(ComboBox1.Count - 1)

With ComboBox1
        Set rng = Range(.RowSource)
        curOne = Format(rng(.ListIndex + 1, i) , Currency)       '< --- here
        curTwo = Format(rng(.ListIndex + 1, i), Currency)        '< ---- and here
TextBox1.Text = curOne
TextBox2.Text = curTwo
End With


something like that maybe ? If not then just get rid of the for next loop and replace the i is above with the 2 and 3 you had originally

Hopefully this helps anyway ( With regards to the format function, here is a reference )

If you need more help post back


Author Comment

ID: 17170919
Thank you!
LVL 23

Expert Comment

ID: 17171129
np - hopefully it worked for you ( I was just wrote the code out from memory )

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

756 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