ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting Values in a Row based on a Certain Criteria (https://www.excelbanter.com/excel-programming/398339-deleting-values-row-based-certain-criteria.html)

cardan

Deleting Values in a Row based on a Certain Criteria
 
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.


Tom Ogilvy

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.



cardan

Deleting Values in a Row based on a Certain Criteria
 
On Sep 28, 11:12 am, Tom Ogilvy
wrote:
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.- Hide quoted text -


- Show quoted text -


Works Great! Thank You!



All times are GMT +1. The time now is 12:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com