Can't find "$" in currency formatted cell

scubadivingfool

New Member
Joined
Jun 17, 2010
Messages
35
I am trying to use the below code to find the cells with a "$" in it. When I manually place the "$" in a cell it works perfectly but when the cell is formatted for currency it does not found anything.

Any help is appreicated.

VBA Code:
Sub Copy_To_Another_Sheet_1()
    Dim FirstAddress As String
    Dim MyArr As Variant
    Dim Rng As Range
    Dim Rcount As Long
    Dim I As Long
    Dim NewSh As Worksheet

    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With

  
    MyArr = Array("$")

    'Add new worksheet to your workbook to copy to
    'You can also use a existing sheet like this
    Set NewSh = Sheets("Sheet2")
    
    With Sheets("Sheet1").Range("A1:Z100")

        Rcount = 0

        For I = LBound(MyArr) To UBound(MyArr)

            Set Rng = .Find(What:=MyArr(I), _
                            After:=.Cells(.Cells.Count), _
                            LookIn:=xlValues, _
                            LookAt:=xlPart, _
                            SearchOrder:=xlByRows, _
                            SearchDirection:=xlNext, _
                            MatchCase:=False)
            If Not Rng Is Nothing Then
                FirstAddress = Rng.Address
                Do
                    Rcount = Rcount + 1
                    Rng.Copy NewSh.Range("A" & Rcount)
                    Set Rng = .FindNext(Rng)
                Loop While Not Rng Is Nothing And Rng.Address <> FirstAddress
            End If
        Next I
    End With

    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
This link should help. Use Number Format to find your data

 
Upvote 0
It seems the link is more for adding a "$" to cells that just have numbers in it and not being about to search for cells that have the "$" in it as a result of being formatted with the currency format
 
Upvote 0
Yes, but it is the concept of how to format, so you need to reverse engineer it as you are looking for data that is formatted in that manner. You apparently have VBA skills that will allow you to do that.
 
Upvote 0
not being about to search for cells that have the "$" in it as a result of being formatted
The cell doesn't have $ in it as the result of being formatted, it still only has the original value. Think of the formatting as a transparent overlay that changes the appearance of whatever is behind it.

Using ctrl f to search the sheet gives you an option to search by format but for whatever reason this errors when you try to repeat the same steps in vba.

As with many things, there is possibly a more practical way to do what you are trying to do, such as looking for intersections of specific row and column headers.
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,297
Members
452,903
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top