excel vba - VBA Find Text in Row 1. Copy & paste below rows if greater than zero -
i have code searches text string in row 1. seraching has no issues .
problem
when text found need macro search column values greater 0 , if found copy whole row , paste sheet 2. have had no success.
please see code below:
private sub btnupdateentry_click() dim stringtofind string dim range stringtofind = application.inputbox("enter string find", "find string") worksheets("skills matrix").activate activesheet.rows(1).select set cell = selection.find(what:=stringtofind, after:=activecell, _ lookin:=xlformulas, lookat:=xlwhole, searchorder:=xlbyrows, _ searchdirection:=xlnext, matchcase:=false, searchformat:=false) each in cell if i.value > 0 i.select activecell.range("1:1").entirerow.select selection.copy sheets("sheet2").range("a65000").end(xlup).offset(1, 0).pastespecial end if next if cell nothing worksheets("data").activate msgbox "string not found" end if end sub thank you.
try this, although doubt need search entire column? loop searching 1 cell. code need amending if search string found more once in first row.
private sub btnupdateentry_click() dim stringtofind string dim range dim cell range stringtofind = application.inputbox("enter string find", "find string") worksheets("skills matrix") set cell = .rows(1).find(what:=stringtofind, lookat:=xlwhole, _ matchcase:=false, searchformat:=false) if not cell nothing each in .range(cell.offset(1), .cells(.rows.count, cell.column).end(xlup)) if isnumeric(i.value) if i.value > 0 i.entirerow.copy sheets("sheet2").range("a" & rows.count).end(xlup).offset(1, 0).pastespecial end if end if next else worksheets("data").activate msgbox "string not found" end if end end sub
Comments
Post a Comment