boiler wrote: ↑05 May 2021, 13:55
Code: Select all
A := {1:10, 2:60, 3:70, 4:50, 5:30}
Xl := ComObjActive("Excel.Application")
Unmatched := {}
for cell, v in Xl.Range("A1:A5") {
found := 0
for key, value in A {
if (value = cell.text) { ; .text instead of .value to remove trailing zeros
found := 1
break
}
}
if !found
Unmatched[cell.address] := cell.text
}
for key, value in Unmatched
output .= key . A_Tab . value "`n"
MsgBox, % output
Sir, there is one problem in your codes-
suppose i have these values in array
A := {1:80, 2:70, 3:50, 4:90, 5:30}
and these values in range
a1:a5-
- 07_05_21 @10_38_14.PNG (2.27 KiB) Viewed 494 times
Now i run these codes-
Code: Select all
A := {1:80, 2:70, 3:50, 4:90, 5:30}
Xl := ComObjActive("Excel.Application")
Unmatched := {}
for cell, v in Xl.Range("A1:A5")
{
found := 0
for key, value in A
{
if (value = cell.text)
{
found := 1
break
}
}
if !found
{
Unmatched[cell.address] := cell.text
}
}
for key, value in Unmatched
output .= key . A_Tab . value "`n"
MsgBox, % output
Then it shows only one value in msgbox-
- 07_05_21 @10_41_03.PNG (7.6 KiB) Viewed 494 times
While it should show two values in msgbox which should be 60 and 50, as there are two 50s in range
a1:a5. One 50 is at
a1 and second is at
a4 , so, while matching the values of range
a1:a5 with the values of array, it should match only one 50 and it can be any one (whether the 50 which falls at
a1 or
a4) and it must show two values in msgbox one is 60 of-course and second is one 50 (which can be any one either of
a4 or of
a1). Please tell me how to solve this problem. Thanks sir...