Error With FIND VBA

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I am having difficulty finding the column number based on the following VBA formula ...

Code:
nlncol = ws_data.Range("A" & dlnrow & ":HO" & dlnrow).Find(What:=entl, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False).Column

I'm getting an "Object variable or With block variable not set" error.

ws_data is recognized as the proper worksheet, dlnrow = 32. So, looking for the column number in row 32 of worksheet ws_data having the value of variable entl.
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
The error means that the value wasn't found.
 
Upvote 0
I suspect that it cannot find the value of entl in row 32
 
Upvote 0
Ah ... that makes sense! Thank you!
Is there an easy way to catch this error?
 
Upvote 0
Something like
Code:
Dim Fnd As Range
Set Fnd = ws_data.Range("A" & dlnrow & ":HO" & dlnrow).Find(What:=entl, lookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False)
If Not Fnd Is Nothing Then nlncol = Fnd.column
 
Upvote 0

Forum statistics

Threads
1,215,335
Messages
6,124,326
Members
449,155
Latest member
ravioli44

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