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-01-2009, 05:19 PM
bdb1974 bdb1974 is offline
Valued Forum Contributor
 
Join Date: 10 Dec 2008
Location: Austin
Posts: 412
bdb1974 is becoming part of the community
Saving Customized Condition in List Box

Please Register to Remove these Ads

Hi all,

Is there a way to save a (customized) condition from the list box?
Everytime I want to check certain values, say for values >0, I would like to not have to set it up. I could then just select it from the dropdown list.

Thanks,

BDB
Reply With Quote
  #2  
Old 07-02-2009, 09:28 AM
MickG's Avatar
MickG MickG is offline
Valued Forum Contributor
 
Join Date: 23 Nov 2007
Location: Banbury,Oxfordshire
Posts: 706
MickG is attaining expert status MickG is attaining expert status
Re: Saving Customized Condition in List Box

Hi, You could use a select case, Example shown below to select a value in Col "C" based on you listbox selection.
Code:
Column(A)       
ListBox List    
Greater Than 0  
Less Than 0     
Equal to 0      
Greater Than 10 
Less Than 10    
Equal to 10
Code:
Private Sub ListBox1_Click()
Dim Rng As Range, Dn As Range, Con
Set Rng = Range(Range("c1"), Range("c" & Rows.Count).End(xlUp))
    For Each Dn In Rng
        Select Case ListBox1.Value
             Case Is = "Greater Than 0": If Dn > 0 Then Dn.Select: Exit Sub
             Case Is = "Equal to 0": If Dn = 0 Then Dn.Select: Exit Sub
             Case Is = "Greater Than 10": If Dn > 10 Then Dn.Select: Exit Sub
             Case Is = "Less Than 10": If Dn < 10 Then Dn.Select: Exit Sub
             Case Is = "Equal to 10": If Dn = 10 Then Dn.Select: Exit Sub
       End Select
    Next Dn
End Sub
Regards Mick

Last edited by MickG; 07-02-2009 at 09:32 AM.
Reply With Quote


Reply

Bookmarks


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