excel - range.replace method doesn't work -
here do:
- replace words in
column d
ofsheet15
according list insheet1
- in
sheet1
,col a
housed list of words want replace, , corresponding words replace next (incol b
)
below code works fine when try in new workbook when place in project, not. debugged line line, no error, words not being replaced accordingly.
i can't figure out what's wrong. here know did go wrong?
sub changeproc() dim fromval string, toval string, cel range, lr long sheet1 'validation list , replacement lr = .cells(.rows.count, 1).end(xlup).row each cel in .range("a1:a1" & lr) 'ori list in col fromval = cel.value2 toval = cel.offset(0, 1).value2 'replacement list in col b 'sheet15.range("d:d").replace fromval, toval, xlwhole, , true 'replace @ data sheet next end end sub
code fine, make sure u use proper sheet names. check in vba project, or sure use sheets("name_here").
and (probably it's obvious, sure :p) uncomment line: 'sheet15.range("d:d").replace fromval, toval, xlwhole, , true 'replace @ data sheet
Comments
Post a Comment