finding a nbr in the mess....

redchief

New Member
Joined
Jan 9, 2025
Messages
6
Office Version
  1. Prefer Not To Say
Platform
  1. Windows
I need help in VBA....
In cell D3 I hv a nbr, I want to search this nbr in column D6 To D9999 and highlight to me in the spreadsheet. I tried using selection.find to locate the nbr. tks v much
 

Excel Facts

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

You do not need VBA. You can do this easily with Conditional Formatting.

Here are the steps:
1. Select the range D6:D9999
2. Go to Conditional Formatting
3. Click "New Rule"
4. Click on "Use a formula to determine which cells to format"
5. Enter this formula:
Excel Formula:
=D6=D$3
6. Click on the Format button
7. Select your desired formatting option
8. Click OK twice

Here is an example of what it looks like:
1736430658546.png


If you really want/need this in VBA, you can set-up this Conditional Formatting Rule in VBA by turning on your Macro Recorder, and record yourself manually performing those steps above. That will give you the VBA code that you need to do this.

Note that one advantage to use Conditional Formatting is it is dynamic, as will updating immediately as you change data.
 
Upvote 0
the nbr I Wan to find is in $D$3 which is generated by the spreadsheet. therefor I could not input the nbr into the dialog box, tks
 
Upvote 0
in the selection.find....the "What:=".... is my big problem....
 
Upvote 0
I'd use conditional formatting myself, same as @Joe4, who has provided detailed steps in Post #2.

But if you're determined to use .Find, then try (to find just the first occurrence):

Code:
Range("D6:D999").Find(What:=Range("D3").Value).Interior.Color = vbYellow
 
Upvote 0
Solution
the nbr I Wan to find is in $D$3 which is generated by the spreadsheet. therefor I could not input the nbr into the dialog box, tks
Dialog box? What dialog box?
The method I proposed uses the cell D3. No value is hard-coded - it will always dynamically use whatever number is in cell D3.
If you change the value in D3, it will automatically and immediately update to reflect that.
 
Upvote 0
ya dats it.... u hv done it....
it works.... man.....
Many tks.... Can't thank you enough...
 
Upvote 0
I'd use conditional formatting myself, same as @Joe4, who has provided detailed steps in Post #2.

But if you're determined to use .Find, then try (to find just the first occurrence):

Code:
Range("D6:D999").Find(What:=Range("D3").Value).Interior.Color = vbYellow
this is the ans.... can't thank you enough.
Many thanks
 
Upvote 0

Forum statistics

Threads
1,226,108
Messages
6,188,978
Members
453,516
Latest member
torisemo

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