excel - Comparing Columns Not Working Due to Apostrophe -
i trying compare 2 columns on different sheets following code:
for = 2 lastrow22 j = 2 lastrow33 if ws2.cells(i, 81) = ws3.cells(j, 10) ws2.cells(i, 1).interior.color = vbgreen end if next j next
i know items in columns match loop not seem find match. further inspected columns , on 1 sheet column cells leading apostrophe , on other sheet not.
i tried looping through sheet , removing apostrophe following code , did not work:
for = 2 lastrow33 if ws3.cells(i, 10) "'*" x = replace(ws2.cells(i, 1), "'", "") ws3.cells(i, 10) = x end if next
any tips on might able match?
use cstr
convert string before comparing. works strings numbers there no type mismatch errors.
final code:
for = 2 lastrow22 j = 2 lastrow33 if cstr(ws2.cells(i, 81)) = cstr(ws3.cells(j, 10)) ws2.cells(i, 1).interior.color = vbgreen end if next j next
Comments
Post a Comment