ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Determine the type of currency in a cell (https://www.excelbanter.com/excel-programming/287512-determine-type-currency-cell.html)

Anders[_6_]

Determine the type of currency in a cell
 
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


---
Message posted from http://www.ExcelForum.com/


Bob Flanagan

Determine the type of currency in a cell
 
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

"Anders " wrote in message
...
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


---
Message posted from http://www.ExcelForum.com/




Ron Rosenfeld[_3_]

Determine the type of currency in a cell
 
On Sun, 11 Jan 2004 06:32:37 -0600, Anders
wrote:

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


All times are GMT +1. The time now is 02:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com