Selection.Find Run time error 91?

DEE_715

New Member
Joined
Feb 12, 2014
Messages
10
Hi All,
Hope you are all well!

I'm struggling to overcome the error in relation to the below code, would anyone be able to help me out?

Basically I keep getting the 'Run time error 91' for the bolded section of the below code.
In the below I'm searching Column E for the value "4" and if/once it is found to essentially ctrl A and name the region "E".
There won't always be a "4" in Column E and in the current data set I'm using there is no "4" so I have tried to use the error handler 'On Error Go To' to overcome but it doesn't seem to be working...

I'm not sure what I'm doing wrong here.

I appreciate any assistance you could provide.
Many Thanks
David


On Error GoTo Next_G:
Columns("E:E").Select
Selection.Find(What:="4", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate

ActiveCell.Select
ActiveCell.CurrentRegion.Select
ActiveWorkbook.Names.Add Name:="E", RefersToR1C1:= _
Selection
ActiveWorkbook.Names("E").Comment = ""
Next_G:
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
How about
VBA Code:
   Dim Fnd As Range

   Set Fnd = Range("E:E").Find("4", , , xlPart, , , , False)
   If Not Fnd Is Nothing Then
      Set Fnd = Fnd.CurrentRegion
      ActiveWorkbook.Names.Add Name:="E", RefersToR1C1:=Fnd
      ActiveWorkbook.Names("E").Comment = ""
   End If
 
Upvote 0

Forum statistics

Threads
1,214,611
Messages
6,120,513
Members
448,967
Latest member
screechyboy79

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