Solved

Syntax for FormatCurrency

Posted on 2006-07-21
5
870 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

831 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