Find cell containing £

coop123

Board Regular
Joined
Dec 18, 2018
Messages
66
Office Version
  1. 365
Hi

I am using the following code to find cells formatted as currency £.
1671701898785.png

Cells.Find(What:="£", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False).Activate
This is giving me the following error message, Run-time error '91': object variable or With block variable not set.

Can someone please give me some help to fix the problem.

Thanks

coop123
 

Attachments

  • 1671701353251.png
    1671701353251.png
    1.9 KB · Views: 6

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Hi

I am using the following code to find cells formatted as currency £.
View attachment 81401

This is giving me the following error message, Run-time error '91': object variable or With block variable not set.

Can someone please give me some help to fix the problem.

Thanks

coop123
try below code

VBA Code:
Sub test()

Dim FindVal As Range

Set FindVal = Cells.Find(What:="£", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=False)

FindVal.Activate

End Sub
 
Upvote 0
Hi anand3dinesh

I copied you code but I still get same error

coop123
"£" symbol, is it you type manually or number formatting?
if it is number formatting then yeah code gives error, because this symbol comes from formatting but it does not exist in your workbook.
I may be wrong. May be excel experts would able to help you
 
Upvote 0
check below code. this highlights number format (£) cells with green


VBA Code:
Sub Macro3()

Dim lrow As Double
lrow = Range("B" & Rows.Count).End(xlUp).Row

For i = 1 To lrow
    If Range("B" & i).NumberFormat = """£ ""0" Then
    Range("B" & i).Interior.ColorIndex = 4
End If
Next

End Sub
 
Last edited:
Upvote 0
I tried this but it didn't highlight anything!!

Is the problem the cell formating?
1671709160665.png


coop123
 
Upvote 0
Sorry there was a space between your number format and value

if your values in column B then, try below. else change column reference

VBA Code:
Sub Macro3()

Dim lrow As Double
lrow = Range("B" & Rows.Count).End(xlUp).Row

For i = 1 To lrow
    If Range("B" & i).NumberFormat = "$0" Then
    Range("B" & i).Interior.ColorIndex = 4
End If
Next

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,540
Messages
6,125,409
Members
449,223
Latest member
Narrian

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