excel - Copying the entire row if the cell isn't one of four determined values -
edited
code answers question
dim integer = 1 sheet1.usedrange.rows.count if cells(i, "c") <> "q" sheet1.rows(i).entirerow.copy sheets("sheet2").cells(i, 1) end if next
edit2
i'm facing minor problems great figure out what's wrong them.
1- code copying cells problem after pasting them in other sheet there gaps on place (they places of non-copied cells)
dim integer = 1 sheet1.usedrange.rows.count if cells(i, "p") <> "q" sheet1.rows(i).entirerow.copy sheets("sheet2").cells(i, 1) end if next
the fix problem add
.end(xlup).offset(1, 0)
after line copy , pasting. tried before used offset(1) , didn't work
2-this code causes excel hang , have force close when reopen copied cells there in new sheet(i kind of know problem, think it's because excel check cells since = 0 tried using same loop previous code kept getting errors)
dim ro long each cell in sheets("sheet1").range("u:u") if (len(cell.value) = 0) ro = (ro + 1) sheets("sheet1").rows(cell.row).copy sheets("sheet3").rows(ro) end if next
the fix #2 add loop of rows count , include it, knew fix had problems syntax. code needed change in line:
for each cell in sheets("sheet1").range("u" & i)
"i" being loop, 1 in code #1
this code iterate of rows in column , check if text q, w or e. if isn't it'll copy row.
sub test() dim integer 'loop move through rows = 1 activesheet.usedrange.rows.count 'checks if contains q, w or e if cells(i, 1) <> "q" , cells(i, 1) <> "w" , cells(i, 1) <> "e" 'copy row rows(i).copy 'you said know how copy part won't include rest... else 'do else end if next end sub
next time attempt problem before asking help. if weren't simple, people wouldn't out much. quick google or search away.
Comments
Post a Comment