Google Answers Logo
View Question
 
Q: Simple Excel Macro Needed ( No Answer,   3 Comments )
Question  
Subject: Simple Excel Macro Needed
Category: Computers > Programming
Asked by: philliprapoport-ga
List Price: $15.00
Posted: 05 Jan 2006 12:15 PST
Expires: 06 Jan 2006 06:30 PST
Question ID: 429566
Hi,

I have an excel spreadsheet that has data in the format (sample):

Date      Customer      Qty         Price       
12/1      AAA           10           1 
12/2      BBB           10           2 
12/2      CCC           15           8
12/3      CCC           12           9

I need a macro that will go through and delete all rows where customer
does not equal "BBB".  The final result should be a sheet with all
transactions of only customer BBB with the relevant data.

Thanks very much for your help
Answer  
There is no answer at this time.

Comments  
Subject: Re: Simple Excel Macro Needed
From: jack_of_few_trades-ga on 05 Jan 2006 13:22 PST
 
If you're not set on a macro, this can be done in about 20 seconds for
any size sheet:

1) Highlight the title row
2) Click on "Data" "Filter" "AutoFilter"
3) Click on the down arrow in the "Customer" cell
4) Select "Custom"
5) Select "Does not equal" and in the other box type "BBB"
6) Delete all rows below the title row
7) Click on "Data" "Filter" "AutoFilter" (to turn off the filter)
Subject: Re: Simple Excel Macro Needed
From: uzzih_perez-ga on 05 Jan 2006 13:39 PST
 
'Change column "B" in "Range("B65536") to your client column.  Then
run the macro.  It will error out when it gets to row one.  But this
will delete out all clients not "BBB".  If you want me to write a
macro where it counts the row and stops on row one, please ask.
 
Sub DeleteIt()

Range("b65536").End(xlUp).Select
Do
    If ActiveCell.Value <> "BBB" Then
        Selection.EntireRow.Delete
    Else
        ActiveCell.Offset(-1, 0).Select
    End If
Loop

End Sub
Subject: Re: Simple Excel Macro Needed
From: nelson-ga on 05 Jan 2006 18:27 PST
 
I vote for the AutoFilter route here.  A macro is overkill when this
is accomplished so easily with built-in functionality.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy