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.
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