Match method always returns false (comparing cell's value to a list)

Phalanx_

New Member
Joined
Apr 15, 2013
Messages
13
Hello everyone,

Here is my situation. I have in my program :
- a list of values of any kind (numbers, strings, etc.) in my column C (most specifically : "C2:C16")
- a list with names of cities (in "G21:G25")

I want to create a sub to compare each content from my column C ("C2:C16") with each string from ("G21:G25"). If there is a match, I want to write the value "10" to the corresponding row of the active cell but in the column G, if no match, then it will write 0.

So for example, if C8 content is "Paris" and "Paris" is also among G21:G25, then G8 is gonna be 10.
If C9 content is "1889" and there is no such value among G21:G25, then G9 is gonna be 0.

Here is my code and problem. So the problem is, it's always returning "false" even if there are some matches between my C list and my G list. I guess one problem might come from IsNumeric (because not every content is numeric) but I tried IsObject, IsArray, whatever was suggested and it always returns false.

Code:
Sub probaCity()
Dim count As Integer, myResult As Boolean

For count = 2 To lastRow
Range("C" & count).Activate
myResult = IsNumeric(Application.Match(ActiveCell.Value, Range("G21:G25"), 0))

If myResult = True Then
Range("G" & ActiveCell.Row).Value = "10"
ElseIf myResult = False Then
Range("G" & ActiveCell.Row).Value = " 0"
End If

Next count
End sub

Thanks in advance for your help !
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,202,973
Messages
6,052,863
Members
444,604
Latest member
Wait what

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