View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default Deleting Values in a Row based on a Certain Criteria

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


"cardan" wrote:

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.