Match failing with Find method (right and wrong match appear)

arthur_w

New Member
Joined
May 12, 2021
Messages
16
Office Version
  1. 365
Platform
  1. Windows
i have

Dim aps As Range
Set aps = Range("A2:A55")
Dim mapa As Range
Set mapa = Sheets("Tom").Range("B6:E19")

For Each c In aps
c.Interior.Color = mapa.Find(c.Value).Interior.Color
Next c

And the numer 101, 102, 103... and 201 dont get the color of themselves, they get the color of 1101, 1102, 1103..... and 1201
But not 202, 203... or 301, 401, just this set. (when there isnt number 1101 or 1102 etc they get the right color, but when there is, get the wrong)

Wtf?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
How about
VBA Code:
c.Interior.Color = mapa.Find(c.Value, , , xlWhole, , , , , False).Interior.Color
 
Upvote 0
Solution
How about
VBA Code:
c.Interior.Color = mapa.Find(c.Value, , , xlWhole, , , , , False).Interior.Color
Works like a glove

I have trobleshooted it some time, and the pattern is simple: if the value of the first cell of the table(selection) "X" is followed by a number with greater units "nX" or "nnX" (ex, 201 followed by 1201 or 5201) it will not compute the first value of the table when searching for it.
If theres no nX it will correctly match x to x, and if x is not the first cell, it will correctly match x to x (I used this, increasing the table range from B6:E19 to B5:E19)
 
Upvote 0

Forum statistics

Threads
1,214,413
Messages
6,119,372
Members
448,888
Latest member
Arle8907

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