Recognize currency in a cell

M

Marcin P

Hi,

I have a spreadsheet which uses different currencies when data are
imported. I'm looking for a method to recognize currency type used in
a cell, for example:

A1: €100 or $100, £100 and so on.

Many thanks.
Marcin
 
F

FSt1

Hi,

I have a spreadsheet which uses different currencies when data are
imported. I'm looking for a method to recognize currency type used in
a cell, for example:

A1: €100 or $100, £100 and so on.

Many thanks.
Marcin

hi
currency type is formating so that is what you would be looking for.
here is a do nothing sniplet that checks for
dollars US.

Sub checkformat()
If Range("B2").NumberFormat = "$#,##0.00" Then
MsgBox "Dollars"
Else
MsgBox "NOT Dollars"
End If
End Sub

you would need to find out what your other currency formats are and
check for each one perhaps in a loop or
something.

Regards
FSt1
 
M

minimaster

hmm..
formating can vary a lot..
there is a better way Typename

Sub testttt4()
Dim c As Range
' Set c = ActiveSheet.[A1]
For Each c In ActiveSheet.UsedRange
If TypeName(c.Value) = "Currency" Then
c.Select
MsgBox " selected cell is a currency cell"
exit sub
End If
Next c
End Sub
 
F

FSt1

hmm..
formating can vary a lot..
there is a better way    Typename

Sub testttt4()
    Dim c As Range
'    Set c = ActiveSheet.[A1]
    For Each c In ActiveSheet.UsedRange
        If TypeName(c.Value) = "Currency" Then
            c.Select
            MsgBox " selected cell is a currency cell"
            exit sub
        End If
    Next c
End Sub

hi,
i took it that he was looking for different currency types not just
currency.

Perhaps the op will clarify for us.

Regards
FSt1
 
G

Gord Dibben

I'm not sure about this.

How should Excel know the currency format for each cell of data imported?

If raw numbers, no format would be displayed.

If the data OP is grabbing comes in with different currency types displayed, I
would say the data is in Text form.

Maybe OP should be looking at LEFT and CODE functions??

=CODE(LEFT,A1) would return 163 for English Pound £

128 for Euro sign €

Of course OP would have to have a table with codes for all currency types
involved.

Easy enough to build one if that's the case.


Gord Dibben MS Excel MVP


hmm..
formating can vary a lot..
there is a better way    Typename

Sub testttt4()
    Dim c As Range
'    Set c = ActiveSheet.[A1]
    For Each c In ActiveSheet.UsedRange
        If TypeName(c.Value) = "Currency" Then
            c.Select
            MsgBox " selected cell is a currency cell"
            exit sub
        End If
    Next c
End Sub

hi,
i took it that he was looking for different currency types not just
currency.

Perhaps the op will clarify for us.

Regards
FSt1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top