excel - How to compare string from cell with string from inputBox() -
i have spread sheet so:
group | name | title ----------------------------------- x ws - x dh - x m - x dh - x ws -
i want loop through cells in name , replace initial there full name in addition adding correct title. script failing accurately compare strings , go if-statement:
sub enternameandtitle() lastcell = inputbox("last cell") rinitials = inputbox("initials") rfullname = inputbox("full name") rtitle = inputbox("title") dim cell range each cell in range("b2:b" & lastcell).cells msgbox (cell.text & " : " & rinitials) if strcomp(ucase(cell.value), ucase(rinitials)) = 0 cell.value = rfullname activesheet.cells(cell.row, cell.column + 1).value = rtitle end if next cell end sub
so first collect data , loop through values. know doing incorrectly? why doesn't compare string accurately?
i don't see wrong, there 2 things try
one use trim make sure neither string has leading or trailing blanks
the 2nd change if if(ucase(trim(cell.value))=ucase(trim(rinitials)))
Comments
Post a Comment