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.
Thanks in advance for your help !
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 !