Solved

Syntax for FormatCurrency

Posted on 2006-07-21
5
868 Views
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
0
Comment
Question by:ca1358
  • 2
  • 2
5 Comments
 
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.
0
 

Author Comment

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

0
 
LVL 23

Accepted Solution

by:
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

Next

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 )

http://msdn2.microsoft.com/en-us/library/y006s0cz.aspx

If you need more help post back

0
 

Author Comment

by:ca1358
ID: 17170919
Thank you!
0
 
LVL 23

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

867 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

12 Experts available now in Live!

Get 1:1 Help Now