Deleting Values in a Row based on a Certain Criteria

C

cardan

Hello,

I am trying to import a worksheet that I copy and paste into a model.
I need to erase the values in a specific row, in columns B thru G if
the first 5 characters in column B contains the word "Total". I also
need to erase the values in a specific row, in columns B thru G if
column C contains "-----------".

I have macro that deletes the rows if a certain criteria is met,
however, deleting rows messes up my formulas on another sheet.

Any suggestions would be greatly appreciated. Thank you in advance.
 
G

Guest

lastrow = Cells(rows.count,2).end(xlup).row
for i = lastrow to 2 step -1
if Instr(1,Trim(cells(i,2)),"total",vbTextCompare) = 1 or _
instr(1,cells(i,3),"-----",vbTextcompare) then
cells(i,2).Resize(1,6).ClearContents
end if
Next i
 
C

cardan

lastrow = Cells(rows.count,2).end(xlup).row
for i = lastrow to 2 step -1
if Instr(1,Trim(cells(i,2)),"total",vbTextCompare) = 1 or _
instr(1,cells(i,3),"-----",vbTextcompare) then
cells(i,2).Resize(1,6).ClearContents
end if
Next i

--
Regards,
Tom Ogilvy








- Show quoted text -

Works Great! Thank You!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top