PC Review


Reply
Thread Tools Rate Thread

Deleting Values in a Row based on a Certain Criteria

 
 
cardan
Guest
Posts: n/a
 
      28th Sep 2007
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.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      28th Sep 2007
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.
>
>

 
Reply With Quote
 
cardan
Guest
Posts: n/a
 
      28th Sep 2007
On Sep 28, 11:12 am, Tom Ogilvy <TomOgi...@discussions.microsoft.com>
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
deleting rows based on criteria gbpg Microsoft Excel Programming 7 16th Aug 2008 05:23 AM
Deleting Rows Based on Criteria bgoode Microsoft Access Macros 1 24th Apr 2008 04:33 PM
Deleting Rows based on multiple criteria cardioblack@gmail.com Microsoft Excel Programming 0 11th Jan 2007 07:40 PM
Deleting entire rows based on certain criteria Nan Microsoft Excel Programming 1 12th Jul 2004 05:04 PM
Deleting rows based on criteria John Walker Microsoft Excel Programming 2 12th Dec 2003 08:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:06 PM.