Excel: search for a word in the column and copy it to another column on the same sheet -


i have excel table rows of data. column j contains various descriptions of goods. need search rows in column word latex , when found, copy word column on same sheet on same row. trying find solution , came macro using autofilter, not working properly. can please me?

sub filterandcopy()      dim dataws worksheet     dim copyws worksheet     dim totrows long     dim lastrow long      set dataws = worksheets("massiv")     set copyws = worksheets("massiv")      dataws         .autofiltermode = false         .range("j:j")              .autofilter field:=1, criteria1:="latex"         end     end      totrows = dataws.range("j:j").rows.count     lastrow = dataws.range("j" & totrows).end(xlup).row     dataws.range("j:j" & lastrow).copy     copyws.range("a6").pastespecial paste:=xlpastevalues     dataws.autofiltermode = false 

with following changes, code should work. i've noted changes in comments in code.

with dataws     .autofiltermode = false     .range("j:j")          'use wildcard search word latex within contents of column j cells           .autofilter field:=1, criteria1:="*latex*"     end end  totrows = dataws.range("j:j").rows.count lastrow = dataws.range("j" & totrows).end(xlup).row 'after filtering, select visible cells in column a... set rng = dataws.range("a2:a" & lastrow).specialcells(xlcelltypevisible) '... , set values "latex" rng.value = "latex" dataws.autofiltermode = false 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -