Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default 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!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting Rows based on multiple criteria [email protected] Excel Programming 0 January 11th 07 07:40 PM
Deleting entire rows based on certain criteria Nan[_4_] Excel Programming 1 July 12th 04 05:04 PM
Deleting rows based on multiple criteria Sandip Shah Excel Programming 3 July 12th 04 01:57 PM
Deleting rows based on cell criteria jgranda Excel Programming 1 April 27th 04 06:41 PM
Deleting rows based on criteria John Walker[_2_] Excel Programming 2 December 12th 03 08:37 PM


All times are GMT +1. The time now is 07:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"