.Find data that is result of formula?

jmpatrick

Active Member
Joined
Aug 17, 2016
Messages
477
Office Version
  1. 365
Platform
  1. Windows
Hello again. Today I'm trying to match data in column 5, which is the result of a formula in a cell.

Here's my code:

VBA Code:
    With Sheets("Models")
    .Columns(5).Find(what:=x, lookat:=xlWhole).EntireRow.Delete
    a = .Range("a2", .Range("a65536").End(xlUp)).Value
    End With
    Me.ModelName.List = a
    End If

...and here's the formula in the column 5 cell:

VBA Code:
=IF(C1=2,B1&" "&"Duplex",IF(AND(C1>=3,C1<="6"),B1&" "&C1&"-Unit",B1))

If E1 for example is Abbeyville, and the value in Me.ModelName.List is also Abbeyville my code above will not find it and delete the row.

Make sense?
 
Last edited:

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
The Find method needs some more parameters to give you the expected result. As a matter of fact, each time you use the Find method, the settings for LookIn, LookAt and SearchOrder are saved.
So if you're looking for values, to be sure you better use a line of code like
Rich (BB code):
.Columns(5).Find(What:=x, LookIn:=xlValues, Lookat:=xlWhole)

In addition, if the What is found, the result will be the first occurrence and if nothing is found your code errors.
 
Upvote 0
Solution
The Find method needs some more parameters to give you the expected result. As a matter of fact, each time you use the Find method, the settings for LookIn, LookAt and SearchOrder are saved.
So if you're looking for values, to be sure you better use a line of code like
Rich (BB code):
.Columns(5).Find(What:=x, LookIn:=xlValues, Lookat:=xlWhole)

In addition, if the What is found, the result will be the first occurrence and if nothing is found your code errors.

Works great! Thanks.
 
Upvote 0
You're welcome and thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,589
Messages
6,120,416
Members
448,960
Latest member
AKSMITH

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