excel - range.replace method doesn't work -


here do:

  • replace words in column d of sheet15 according list in sheet1
  • in sheet1, col a housed list of words want replace, , corresponding words replace next (in col 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

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -