|
Subject:
|
check a cell to see if it has a currency code
|
|
Posted By:
|
crmpicco
|
Post Date:
|
12/16/2005 10:09:50 AM
|
i am looking for a function that will check a cell to see if it has a currency code (e.g. GBP) inside it.
www.crmpicco.co.uk
|
|
Reply By:
|
crmpicco
|
Reply Date:
|
12/19/2005 5:50:18 AM
|
is there a vbCurrency/varType? Cant seem to get it working.
www.crmpicco.co.uk
|
|
Reply By:
|
shattered
|
Reply Date:
|
12/19/2005 8:33:49 AM
|
You can check for currency by checking to see if VarType(Cell Value) = 6
In tests however there is a flaw in this plan, in that it only seems to recognise the values in £ - if you use the $ symbol (or any other currency) it doesn't recognise it
It will recognise the £ symbol used in currency or accounting format.
a fairly simplistic function for that would be
Function IsCurrency(sSheet As String, sRange As String) As Boolean If VarType(Worksheets(sSheet).Range(sRange).Value) = 6 Then IsCurrency = True Else IsCurrency = False End If End Function
|
|
Reply By:
|
shattered
|
Reply Date:
|
12/19/2005 9:10:59 AM
|
another way would be to check the number format along the lines of
InStr(1, ActiveSheet.Range(sRange).NumberFormat, "$") > 0
and process accordingly - that should pick up all curencies..
|