problem description: find instr(which number) check if instr value carrying character front of or not.(for ex. 123, x123). if instr or instr character matches value sheet 2 msg box yes.
problem: can find instr can't check if instr containing char front of or not. how check it, left(chr) function or something. here code doing finding instr not chr instr.
sub tym() dim ws1 worksheet, wb workbook, ws2 worksheet dim b, c range, rngnums range, rngtext range dim dnums, dtext, rn long, rt long, t, m set wb = activeworkbook set ws1 = wb.worksheets("sheet1") set ws2 = wb.worksheets("sheet2") set c = wb.worksheets("sheet3").cells(rows.count, 1).end(xlup).offset(1, 0) set rngnums = ws1.range(ws1.range("a1"), ws1.cells(rows.count, 1).end(xlup)) dnums = rngnums.value set rngtext = ws2.range(ws2.range("a1"), ws2.cells(rows.count, 1).end(xlup)) dtext = rngtext.value rn = 1 ubound(dnums, 1) b = "-" & dnums(rn, 1) & "-" (right here im defining find instr how add function find char front of instr) rt = 1 ubound(dtext, 1) if instr(1, dtext(rt, 1), b) > 0 msgbox "yes" end if next rt next rn end sub
you can test presence of non-digit characters between dashes using
if "xxx-x123-xxx" "*-[!0-9]-*"
edit: if want check number in question, non-numeric characters on each side of it, then:
dim v, p v = 123 p = "*[!0-9]" & v & "[!0-9]*" if "xxx-x123-xxx" p 'matched pattern... end if
Comments
Post a Comment