PC Review


Reply
Thread Tools Rate Thread

delete rows based on 2 conditions of that row

 
 
Don Doan
Guest
Posts: n/a
 
      2nd Jun 2009
Hi there,
I have a spreadsheet that had data occupied from column A to T. How can I
create a macro that would look at just column E and G. Starting from row 2,
for each row, if cell in column E had the first 4 letters BSDT AND for each
cell in column E, if the first 2 letters are CA...then keep that row. If not,
then delete that entire row. Keep doing that until there is a blank line.
Now, cells in column E can be something like BSDTU33AITD and cells in column
G can be something like CA28464746

Thanks for your advise.
 
Reply With Quote
 
 
 
 
Patrick Molloy
Guest
Posts: n/a
 
      2nd Jun 2009

for rw = range("A1").End(xldown).Row to 2 step -1
if NOT ( left(cells(rw,"E").Value,4) = "BSDT" AND
left(cells(rw,"G").Value,2) = "CA") Then
rows(rw).delete
end if
next


you could also add an auto filter and then you'd just cut/paste the rows...



"Don Doan" <(E-Mail Removed)> wrote in message
news7B5D113-79C8-4819-B01B-(E-Mail Removed)...
> Hi there,
> I have a spreadsheet that had data occupied from column A to T. How can I
> create a macro that would look at just column E and G. Starting from row
> 2,
> for each row, if cell in column E had the first 4 letters BSDT AND for
> each
> cell in column E, if the first 2 letters are CA...then keep that row. If
> not,
> then delete that entire row. Keep doing that until there is a blank line.
> Now, cells in column E can be something like BSDTU33AITD and cells in
> column
> G can be something like CA28464746
>
> Thanks for your advise.


 
Reply With Quote
 
Don Doan
Guest
Posts: n/a
 
      2nd Jun 2009
Thanks,
It works perfectly.

"Patrick Molloy" wrote:

>
> for rw = range("A1").End(xldown).Row to 2 step -1
> if NOT ( left(cells(rw,"E").Value,4) = "BSDT" AND
> left(cells(rw,"G").Value,2) = "CA") Then
> rows(rw).delete
> end if
> next
>
>
> you could also add an auto filter and then you'd just cut/paste the rows...
>
>
>
> "Don Doan" <(E-Mail Removed)> wrote in message
> news7B5D113-79C8-4819-B01B-(E-Mail Removed)...
> > Hi there,
> > I have a spreadsheet that had data occupied from column A to T. How can I
> > create a macro that would look at just column E and G. Starting from row
> > 2,
> > for each row, if cell in column E had the first 4 letters BSDT AND for
> > each
> > cell in column E, if the first 2 letters are CA...then keep that row. If
> > not,
> > then delete that entire row. Keep doing that until there is a blank line.
> > Now, cells in column E can be something like BSDTU33AITD and cells in
> > column
> > G can be something like CA28464746
> >
> > Thanks for your advise.

>

 
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
Deletion of rows based on Conditions =?Utf-8?B?SmVhbg==?= Microsoft Access Queries 3 17th May 2007 11:26 PM
Conditional Formatting of Rows Based On More Than 4 Conditions =?Utf-8?B?VFJlbmljaw==?= Microsoft Excel Programming 3 6th Apr 2005 04:25 PM
Deleting rows based upon Error conditions =?Utf-8?B?SkVmZg==?= Microsoft Excel Programming 1 28th Dec 2004 09:55 PM
How to Delete Rows Based on Conditions? hce Microsoft Excel Misc 4 11th May 2004 03:48 PM
How to Delete Rows based on conditions? hce Microsoft Excel Misc 4 10th May 2004 11:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:09 PM.