Determine the type of currency in a cell

  • Thread starter Thread starter Anders
  • Start date Start date
A

Anders

Hi!
I have an excel sheet where some cells are formated as Currency Euro
others as Currency Brittish Pund and others as Currency American
Dollars. I would now like, in Vba, to determine what type of currency a
specific cell is containing. Is that possible?
I'm looking for some thing like:
Range(A1).CurrencyType=Euro

Any suggestions are appreciated.

Thanks

Anders
 
Anders, you can extract the first formatted character in a cell like this:

dim firstC as string
firstC = left(ActiveCell.Text,1)

You can then test this against the character for the currency. For example:

if FirstC ="$" then

I don't know the symbols for the Euro or British pound, but they shoud be
easy to find.

Bob Flanagan
Macro Systems
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 
Hi!
I have an excel sheet where some cells are formated as Currency Euro
others as Currency Brittish Pund and others as Currency American
Dollars. I would now like, in Vba, to determine what type of currency a
specific cell is containing. Is that possible?
I'm looking for some thing like:
Range(A1).CurrencyType=Euro

Any suggestions are appreciated.

Thanks

Anders

It may depend on what you want to do with the data, but perhaps this will help:

=================
Sub CurrencyFormat()

Dim CurFmt As String

CurFmt = Selection.NumberFormat

If InStr(1, CurFmt, "£") Then CurFmt = "British Pound"
If InStr(1, CurFmt, "€") Then CurFmt = "Euro"

'Note that non-USD formats may include the '$', so test for this last.

If InStr(1, CurFmt, "$") Then CurFmt = "US Dollar"

MsgBox ("Format of Cell " & Selection.Address & " is " & CurFmt)

End Sub
==========================


--ron
 
Back
Top