Replace loop in VBA -


i have csv files special characters such 'è' instead of 'é' (the csv file in french). referenced special characters , trying write code vba it. unfortunatelly not working. code :

sub replacetest()  ' referenced 35 issues      dim replacewhat(35) variant     dim replaceby(35)  variant  ' reference special caracters , link them ones     application.sheets("specialcaracters").select     replacewhat(35) = application.range("a1:a35").value      replaceby(35) = application.range("b1:b35").value      dim integer     = 0 34         application.sheets("sheet1").select         activesheet.columns("a:ah").select          selection.replace what:=remplacerwhat(i), replacement:=remplacerby(i),  lookat:=xlpart, _         searchorder:=xlbyrows, matchcase:=false, searchformat:=false, _         replaceformat:=false     next end sub 

any idea? thanks

assuming having this:

specialcharacters sheet \ | | b 1 | à | 2 | é | e 3 | ó | o 

you can use following method iterate through special character rows , replace occurrences in sheet or range.

option explicit  sub replacespecialcharacters(replacerange range)     dim specialcharsheet worksheet     dim replacewhat string     dim replaceby  string     dim rowindex long      set specialcharsheet = sheets("specialcharacters")     rowindex = 1 specialcharsheet.usedrange.rows.count         replacewhat = specialcharsheet.cells(rowindex, 1).value         replaceby = specialcharsheet.cells(rowindex, 2).value          replacerange.replace what:=replacewhat, replacement:=replaceby, _             lookat:=xlpart, searchorder:=xlbyrows, matchcase:=false, _             searchformat:=false, replaceformat:=false     next rowindex end sub  sub replacesheet1()     ' if using hard coded range     replacespecialcharacters sheet1.columns("a:ah")      ' if using selection     replacespecialcharacters selection end sub 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -