Solved

How to determine if a format has US dollar sign in Excel

Posted on 2011-03-23
10
386 Views
Last Modified: 2012-06-22
Is there a way to determine if a cell has a US currency set?
0
Comment
Question by:rayluvs
  • 5
  • 4
10 Comments
 
LVL 33

Expert Comment

by:jppinto
ID: 35203352
If the value is on cell A1, you can check if the dollar sign is on the first position with this:

=IF(LEFT(A1,1)="$","True","False")

jppinto
0
 
LVL 33

Assisted Solution

by:jppinto
jppinto earned 450 total points
ID: 35203429
Or you can use a VBA if the cell is formated as currency, like the attached example.

jppinto
Currency.xlsm
0
 
LVL 33

Assisted Solution

by:jppinto
jppinto earned 450 total points
ID: 35203438
Or even like this (another VBA version).

Sub test()

    If InStr(1, Range("a1").Text, "$") > 0 Then
        ' US currency
        MsgBox ("US Currency")
    End If

End Sub

Currency.xlsm
0
 
LVL 23

Assisted Solution

by:Michael74
Michael74 earned 50 total points
ID: 35203445
The formula above works.

You can also
   - check manually by right clicking on the cell selecting format cells and looking at the current formatting
   - vba you can use something like the attached code

Michael
Function hasDollarFormat(Cell As Range) As Boolean
   If Left(Cell.NumberFormat, 1) = "$" Then
      hasDollarFormat = True
   Else
      hasDollarFormat = False
   End If
End Function

Open in new window

0
 

Author Comment

by:rayluvs
ID: 35203662
Thanx, and it perfect if I needed a button, but what I need is within the Excel in report format.  I created an Excel with jppinto initial formula...

Hope this helps
DetectCurrency.xlsx
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 33

Accepted Solution

by:
jppinto earned 450 total points
ID: 35205556
I've created a UDF (User Defined Function) that will work like this:

=HasDollar(F10)

It will return True or False depending if the cell has a $ sign in it. The code is like this:

Function HasDollar(cell As Range) As Boolean

    If InStr(1, cell.Text, "$") > 0 Then
        HasDollar = True
    Else
        HasDollar = False
    End If

End Function

You have to insert it into a VBA Module so that you can call it on your sheet. Please check the attached working example.

jppinto

DetectCurrency.xlsm
0
 

Author Comment

by:rayluvs
ID: 35207421
Worked.

Just to make sure, there is no Excel function that does this right (we have to create the function)?
0
 
LVL 33

Assisted Solution

by:jppinto
jppinto earned 450 total points
ID: 35208832
Right! No Excel function for this! You need VBA...

You see a value on a cell formated like currency like "$ 450" but the real value of the cell is "450". So you can't get the left most character from the cell because it would return 4 instead of the $ sign, unless the value on the cell would be a text value and it's real value is like "$ 450". Then you could use a LEFT(A1,1)="$" to check if there is a $ sign, wich is not the case.

jppinto
0
 

Author Comment

by:rayluvs
ID: 35209101
Thanx lots
0
 

Author Closing Comment

by:rayluvs
ID: 35209145
thanx
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

747 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now