excel - if cell contains specific text, copy whole row + next row -
i new vbs , need help.
i have sheet1 , sheet2. raw data in sheet1 column , sheet2 summary report. want script search each cell in column , search "grade a". if find, copy entired row contains grade word , copy next row , paste in sheet2. here example.
sheet1:
a b c gradea sdfasdf sadfsadf address sadfas sdfsadfs grade b sadfsd dgfdsgdf address sdfasf ertertewt grade c fhgfdgh ukjtyuyt gradea hhh lll address ppp hhh sheet2 shoud after running script.
a b c gradea sdfasdf sadfsadf address sadfas sdfsadfs gradea hhh lll address ppp hhh thank in advance.
try following code
sub test() each cell in sheets(1).range("a:a") if cell.value = "gradea" matchrow = cell.row rows(matchrow & ":" & matchrow + 1).select selection.copy sheets("sheet2").select lastrow = activesheet.usedrange.rows.count if lastrow > 1 lastrow = lastrow + 1 activesheet.range("a" & lastrow).select activesheet.paste sheets("sheet1").select end if next end sub
Comments
Post a Comment