+ Reply to Thread
Results 1 to 4 of 4

If(SEARCH(....... statement with dropdown list....

Hybrid View

  1. #1
    Registered User
    Join Date
    05-01-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    2

    If(SEARCH(....... statement with dropdown list....

    Hi,

    I'm wondering if someone could help me with my excel project.

    I already have my formula drafted. But my problem is how the cell would have a drop down list if the word "MI1" is found on previous cell. Please see the formula in red.

    =IF(ISNUMBER(SEARCH("CC1",H3)), "Payment", IF(ISNUMBER(SEARCH("VP5",H3)), "Payment", IF(ISNUMBER(SEARCH("PP12",H3)), "Payment", IF(ISNUMBER(SEARCH("PC8",H3)), "Payment", IF(ISNUMBER(SEARCH("PC9",H3)), "Payment", IF(ISNUMBER(SEARCH("RE1",H3)), "Payment", IF(ISNUMBER(SEARCH("AB2",H3)), "Balance Inquiry", IF(ISNUMBER(SEARCH("QB1",H3)), "Billing", IF(ISNUMBER(SEARCH("QB2",H3)), "Billing", IF(ISNUMBER(SEARCH("QB3",H3)), "Billing", IF(ISNUMBER(SEARCH("QB4",H3)), "Billing", IF(ISNUMBER(SEARCH("CB6",H3)), "Billing", IF(ISNUMBER(SEARCH("SR7",H3)), "Billing", IF(ISNUMBER(SEARCH("SR8",H3)), "Billing", IF(ISNUMBER(SEARCH("CB7",H3)), "Insurance", IF(ISNUMBER(SEARCH("IU6",H3)), "Insurance", IF(ISNUMBER(SEARCH("IU7",H3)), "Insurance", IF(ISNUMBER(SEARCH("SI3",H3)), "Insurance", IF(ISNUMBER(SEARCH("VC10",H3)), "Insurance", IF(ISNUMBER(SEARCH("AT3",H3)), "Legal Request", IF(ISNUMBER(SEARCH("AT4",H3)), "Legal Request", IF(ISNUMBER(SEARCH("AT5",H3)), "Legal Request", IF(ISNUMBER(SEARCH("MI1",H3)), "Drop down list", IF(ISNUMBER(SEARCH("RI1",H3)), "Open To-Do/ff-up",""))))))))))))))))))))))))



    What I need is that the cell would only show the dropdown list if it found the word "MI1" on the previous cell, otherwise, no dropdown list should be shown....

    Hope to hear an answer...

    Thanks in advance...

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: If(SEARCH(....... statement with dropdown list....

    raineb,

    Welcome to the forum!
    Unfortunately, what you're asking for cannot be done with a formula. It would require VBA (macro).
    However, because your formula was making my eyes bleed, here's a cleaned up version:

    =IF(SUM(COUNTIF(H3,"*"&{"QB1","QB2","QB3","QB4","CB6","SR7","SR8"}&"*"))>0,"Billing",IF(SUM(COUNTIF(H3,"*"&{"CC1","VP5","PP12","PC8","PC9","RE1"}&"*"))>0,"Payment",IF(SUM(COUNTIF(H3,"*"&{"CB7","IU6","IU7","SI3","VC10"}&"*"))>0,"Insurance",IF(SUM(COUNTIF(H3,"*AT"&{3,4,5}&"*"))>0,"Legal Request",IF(COUNTIF(H3,"*AB2*")>0,"Balance Inquiry",IF(COUNTIF(H3,"*RI1*")>0,"Open To-DO/ff-up",IF(COUNTIF(H3,"*MI1*")>0,"Drop down list","")))))))

    Note the formula could be even shorter if you had a reference table with what to look for and what the result should be.
    If you are interested in a VBA solution for the drop-down list, let me know
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    05-01-2013
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: If(SEARCH(....... statement with dropdown list....

    Thanks for your quick response tigeravatar.

    Sorry to make your eyes bleed... ^^ haha... It's my first time doing excel on my own...

    Yes, I'm very much interested in VBA solution... Hope you could help me...


    Thanks much in advance...

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: If(SEARCH(....... statement with dropdown list....

    raineb,

    Attached is an example workbook based on the criteria described.
    It has two worksheets, "Sheet1" and "Lists"

    In sheet "Sheet1":
    Row 2 is a header row so actual data starts on row 3
    Column H is where you can enter the various items shown in the formula (QB1, CB7, VC10, RE1, MI1, etc)
    Column I is the result based on what you chose/entered in the corresponding row in column H. Column I is governed by the macro code provided below.

    In sheet "Lists":
    Row 1 is a header row so actual data starts on row 2
    Column A is the list of items that "Sheet1" column H can accept
    Column B contains the various results for the entries available for "Sheet1" column H
    Column A is defined by a dynamic named range with name "listHeaderH" whose formula is:
    =Lists!$A$2:INDEX(Lists!$A:$A,MAX(2,COUNTA(Lists!$A:$A)))
    Column D contains the drop down list that will be provided when a user selects "MI1" as the entry in "Sheet1" column H
    The first line in the drop down list is "Select Item" so that the user will know that it is a drop-down list
    This is further emphasized with conditional formatting on "Sheet1"
    The drop-down list is also defined by a dynamic named range with name "listItems" whose formula is:
    =Lists!$D$2:INDEX(Lists!$D:$D,MAX(2,COUNTA(Lists!$D:$D)))
    (To view the named ranges, go to the Formulas tab and click Name Manager).

    Lastly, in the "Sheet1" code module this worksheet_change event code:
    Private Sub Worksheet_Change(ByVal Target As Range)
        
        Dim rngChg As Range
        Dim ChgCell As Range
        Dim rngFound As Range
        Dim rngDest As Range
        
        Set rngChg = Intersect(Target, Me.Range("H3:H" & Rows.Count))
        Application.EnableEvents = False
        
        If Not rngChg Is Nothing Then
            For Each ChgCell In rngChg.Cells
                Set rngDest = Me.Cells(ChgCell.Row, "I")
                rngDest.Clear
                If Len(ChgCell.Text) > 0 Then
                    Set rngFound = Sheets("Lists").Columns("A").Find(ChgCell.Text, , xlValues, xlWhole)
                    If Not rngFound Is Nothing Then
                        Select Case (rngFound.Offset(, 1).Text <> "<DropDown>")
                            Case True:  rngDest.Value = rngFound.Offset(, 1).Value
                            Case Else
                                With rngDest.Validation
                                    .Delete
                                    .Add xlValidateList, , , "=listItems"
                                End With
                                rngDest.Value = Sheets("Lists").Range("listItems").Cells(1).Text
                        End Select
                    End If
                End If
            Next ChgCell
        End If
        
        Application.EnableEvents = True
        
    End Sub

    To view the code, press Alt+F11 to open the Visual Basic Editor (VBE) and then double click on Sheet1.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1