Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #1  
Old 07-04-2009, 12:46 PM
duugg duugg is offline
Valued Forum Contributor
 
Join Date: 11 Apr 2006
MS Office Version:2003
Posts: 397
duugg is becoming part of the community
Delete certain rows with an input box

Please Register to Remove these Ads

Hello all,

I would like a macro that does this...

Note for below that the "state" column will never be in a fixed column position, so this macro must search for "state" by name and not column position.



1. Find the column named "state"
2. Bring up a message box saying "Please enter the state/states you would like to use, separate each state with a comma"
3. The user would then enter in each state/states they want to use and press "OK"
4. The macro then deletes ALL ENTIRE ROWS NOT matching the state/states IN THAT COLUMN that were entered in the message box by the user (except the header row of course).

To clarify number 4 further, the macro should ONLY look in the "state" column when deciding whether to delete the WHOLE ROW or not.

5. The case should be non case-sensitive, for the "active worksheet", and if possible, should work whether the user enters in more states with either

a) comma state

or

b) comma space state

6. Also, I'm only using "states" for example reasons only but actual text length can more more characters long. The criteria entered in the message box should not be limited to two characters.


thanks much!

Last edited by duugg; 07-23-2009 at 11:24 AM. Reason: searchability
Reply With Quote
  #2  
Old 07-04-2009, 03:18 PM
mrice's Avatar
mrice mrice is offline
Forum Guru
 
Join Date: 22 Jun 2004
Location: Surrey, England
MS Office Version:Excel 2007
Posts: 1,857
mrice has been very helpful
Re: Delete all rows not matching several criteria via input box...

Try the attachment, you can see the code by hitting Alt F11.
Attached Files
File Type: xls Book1.xls (34.5 KB, 9 views)
__________________
Martin

Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.
Reply With Quote
  #3  
Old 07-05-2009, 11:18 AM
duugg duugg is offline
Valued Forum Contributor
 
Join Date: 11 Apr 2006
MS Office Version:2003
Posts: 397
duugg is becoming part of the community
Re: Delete all rows not matching several criteria via input box...

mrice,

worked awesome!

thanks much!
Reply With Quote


Reply

Bookmarks

Tags
criteria , message box


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump