Results 1 to 3 of 3

Mixed Bag - VBA index/match, ComboBox Text derived from Named List based on cell formula,

Threaded View

KentK Mixed Bag - VBA index/match,... 10-17-2018, 12:40 PM
KentK Re: Mixed Bag - VBA... 10-17-2018, 12:42 PM
KentK Re: Mixed Bag - VBA... 10-19-2018, 03:43 PM
  1. #1
    Registered User
    Join Date
    09-11-2018
    Location
    San Jose, California
    MS-Off Ver
    2016
    Posts
    3

    Mixed Bag - VBA index/match, ComboBox Text derived from Named List based on cell formula,

    Afternoon everyone,

    I'm really struggling to figure out what is going on now. I've tried to create an excel document that will act as a job tracker throughout various phases of construction. The initial worksheet layout is based on shapes used as tabs, which determine which columns are visible when clicked from a VBA Module. (Unhide All Columns to review)

    From there, I've inserted 3 ActivX ComboBoxes that are meant to be used as alternative search fields. The user will rarely have/know all three of the values so I want to make sure they can populate all of the available data by using one of these 3. I initially attempted to use 3 option buttons that would alternate linkedcell and rowsource via macro, but that started to get funky. For now, I'm stalled at the ComboBox1_Change event and haven't proceeded with the other two in VBA . When the combobox1_change event starts, the other two comboboxes are hidden and textboxes are visible instead, and will populate with the related data.

    When the ComboBoxes are selected and the user starts typing, the rowsource is formula driven based on what is typed, and eliminates all options not containing the data typed, dynamically reducing the dropdown list. Extra columns were added to generate this effect and those in-cell formulas can be found in their respective "If found, Frequency, & Searchable List" columns.

    The current data range begins with Column FV and extends through NE

    This whole setup feels like a frankenstein of all sorts of approaches and now when I type in ComboBox1, excel crashes. Yesterday morning I had only 5 Dim'd ranges in the ComboBox1_Change macro and I was able to get the dynamic dropdown.

    All dim'd ranges are tied to their respective named ranges found in the name manager. This may be uneccesary or overkill and maybe a table is needed instead?

    Right now I think I just need someone to tell me what the heck I'm doing wrong, and point me in the right direction. I'm a VBA novice and have scrapped together what I have from various google results, and tutorials that I could find. Some of the Macros were tailored to fit my needs and may just be too much for Excel to process?

    I may need some advice on which sub events I should be assigning certain macros to eliminate the current headache.

    Some additional observations:

    There are three command buttons on the worksheet. (Add entry, Update Entry, and Clear Fields.) Add entry brings up a userform that works. Clear Entry clears all combobox values which then clears the dependant textboxes. Update Command Button is not yet programmed.

    Not able to get date values to populate as dates in the linked textboxes. I don't see how to format the textbox values to reflect this format.


    If I start typing "R" for "RDHA" the dropdown list seems unaffected. However, if I start to type "N" for "NWHL", excel crashes when I type N every time. I haven't gone through the alphabet, but I wonder if there is some significance to that...

    *edit* - I've now cycled through the entire alphabet, as well as numerals and only two letters cause an immediate crash of Excel. "N" and "S"... this occurs as a first letter and as a secondary letter.


    These are the current Worksheet Macros I have at a glance


    Private Sub AddBttn_Click()
    UserForm1.Show
    End Sub
    
    Private Sub WorkSheet1_Initialize()
        With Sheet1
            TextBox4.Visible = False
            TextBox5.Visible = False
            TextBox6.Visible = False
        End With
    End Sub
    
    Private Sub ClrBttn_Click()
        With Sheet1
            ComboBox1.Value = Null
            ComboBox1.Visible = True
            TextBox4.Visible = False
            ComboBox2.Value = Null
            ComboBox2.Visible = True
            TextBox5.Visible = False
            ComboBox3.Value = Null
            ComboBox3.Visible = True
            TextBox6.Visible = False
        End With
    End Sub
    
    Private Sub ComboBox1_Change()
        With Sheet1
        
            ComboBox1.DropDown
            ComboBox1.LinkedCell = "GA1"
            ComboBox1.ListFillRange = "FNAME"
            ComboBox2.Visible = False
            ComboBox3.Visible = False
            TextBox4.Visible = False
            TextBox5.Visible = True
            TextBox6.Visible = True
            
                Dim rng1 As Range
                    Set rng1 = ActiveWorkbook.Names("FILE_NAME").RefersToRange
                
                'Entry Number used as reference for Index Match as follows...
                Dim rng2 As Range
                    Set rng2 = ActiveWorkbook.Names("ENTRY").RefersToRange
                        EntryNo = Application.IfError(Application.Index(rng2, Application.Match(ComboBox1.Text, rng1, 0)), "")
                
                'File Name TextBox
                        TextBox4.Text = Application.IfError(Application.Index(rng1, Application.Match(EntryNo, rng2, 0)), "")
    
                'Hub Name
                Dim rng3 As Range
                    Set rng3 = ActiveWorkbook.Names("HUB").RefersToRange
                        TextBox1.Text = Application.IfError(Application.Index(rng3, Application.Match(EntryNo, rng2, 0)), "")
    
                'NFID
                Dim rng4 As Range
                    Set rng4 = ActiveWorkbook.Names("NFID").RefersToRange
                        TextBox5.Text = Application.IfError(Application.Index(rng4, Application.Match(EntryNo, rng2, 0)), "")
    
                'Date Received
                Dim rng5 As Range
                    Set rng5 = ActiveWorkbook.Names("DATE_RECEIVED").RefersToRange
                        TextBox2.Text = Application.IfError(Application.Index(rng5, Application.Match(EntryNo, rng2, 0)), "")
    
                'Aerial Polyset(1)
                Dim rng6 As Range
                    Set rng6 = ActiveWorkbook.Names("Aerial_POLYSET__1").RefersToRange
                        TextBox6.Text = Application.IfError(Application.Index(rng6, Application.Match(EntryNo, rng2, 0)), "")
    
                'FQN ID
                Dim rng7 As Range
                    Set rng7 = ActiveWorkbook.Names("FQN_ID").RefersToRange
                        TextBox3.Text = Application.IfError(Application.Index(rng7, Application.Match(EntryNo, rng2, 0)), "")
    
                'Primary Site
                Dim rng8 As Range
                    Set rng8 = ActiveWorkbook.Names("Primary_Site").RefersToRange
                        TextBox7.Text = Application.IfError(Application.Index(rng8, Application.Match(EntryNo, rng2, 0)), "")     
           
                'Secondary Sites
                Dim rng9 As Range
                    Set rng9 = ActiveWorkbook.Names("Secondary_Sites").RefersToRange
                        TextBox8.Text = Application.IfError(Application.Index(rng8, Application.Match(EntryNo, rng2, 0)), "")
    
                'Aerial Polyset(2)
                Dim rng10 As Range
                    Set rng10 = ActiveWorkbook.Names("Aerial_POLYSET__2").RefersToRange
                        TextBox9.Text = Application.IfError(Application.Index(rng10, Application.Match(EntryNo, rng2, 0)), "") 
    
                'Aerial Polyset(3)
                Dim rng11 As Range
                    Set rng11 = ActiveWorkbook.Names("Aerial_POLYSET__3").RefersToRange
                        TextBox10.Text = Application.IfError(Application.Index(rng11, Application.Match(EntryNo, rng2, 0)), "")
                        
                'Aerial Polyset(4)
                Dim rng12 As Range
                    Set rng12 = ActiveWorkbook.Names("Aerial_POLYSET__4").RefersToRange
                        TextBox11.Text = Application.IfError(Application.Index(rng12, Application.Match(EntryNo, rng2, 0)), "")
                            
                'Aerial Polyset(5)
                Dim rng13 As Range
                    Set rng13 = ActiveWorkbook.Names("Aerial_POLYSET__5").RefersToRange
                        TextBox12.Text = Application.IfError(Application.Index(rng13, Application.Match(EntryNo, rng2, 0)), "")
                        
                'Aerial Polyset(6)
                Dim rng14 As Range
                    Set rng14 = ActiveWorkbook.Names("Aerial_POLYSET__6").RefersToRange
                        TextBox13.Text = Application.IfError(Application.Index(rng14, Application.Match(EntryNo, rng2, 0)), "")
                        
                'Aerial Polyset(7)
                Dim rng15 As Range
                    Set rng15 = ActiveWorkbook.Names("Aerial_POLYSET__7").RefersToRange
                        TextBox14.Text = Application.IfError(Application.Index(rng15, Application.Match(EntryNo, rng2, 0)), "")
                        
                'Aerial Polyset(8)
                Dim rng16 As Range
                    Set rng16 = ActiveWorkbook.Names("Aerial_POLYSET__8").RefersToRange
                        TextBox15.Text = Application.IfError(Application.Index(rng16, Application.Match(EntryNo, rng2, 0)), "")
                        
                'Underground Polyset(1)
                Dim rng17 As Range
                    Set rng17 = ActiveWorkbook.Names("Underground_POLYSET__1").RefersToRange
                        TextBox16.Text = Application.IfError(Application.Index(rng17, Application.Match(EntryNo, rng2, 0)), "")
                        
                'Underground Polyset(2)
                Dim rng18 As Range
                    Set rng18 = ActiveWorkbook.Names("Underground_POLYSET__2").RefersToRange
                        TextBox17.Text = Application.IfError(Application.Index(rng18, Application.Match(EntryNo, rng2, 0)), "")
                        
                'Underground Polyset(3)
                Dim rng19 As Range
                    Set rng19 = ActiveWorkbook.Names("Underground_POLYSET__3").RefersToRange
                        TextBox18.Text = Application.IfError(Application.Index(rng19, Application.Match(EntryNo, rng2, 0)), "")
                        
                'Underground Polyset(4)
                Dim rng20 As Range
                    Set rng20 = ActiveWorkbook.Names("Underground_POLYSET__4").RefersToRange
                        TextBox19.Text = Application.IfError(Application.Index(rng20, Application.Match(EntryNo, rng2, 0)), "")
                        
                'Underground Polyset(5)
                Dim rng21 As Range
                    Set rng21 = ActiveWorkbook.Names("Underground_POLYSET__5").RefersToRange
                        TextBox20.Text = Application.IfError(Application.Index(rng21, Application.Match(EntryNo, rng2, 0)), "")
                        
                'Underground Polyset(6)
                Dim rng22 As Range
                    Set rng22 = ActiveWorkbook.Names("Underground_POLYSET__6").RefersToRange
                        TextBox21.Text = Application.IfError(Application.Index(rng22, Application.Match(EntryNo, rng2, 0)), "")
                        
                'Underground Polyset(7)
                Dim rng23 As Range
                    Set rng23 = ActiveWorkbook.Names("Underground_POLYSET__7").RefersToRange
                        TextBox22.Text = Application.IfError(Application.Index(rng23, Application.Match(EntryNo, rng2, 0)), "")
                        
                'Underground Polyset(8)
                Dim rng24 As Range
                    Set rng24 = ActiveWorkbook.Names("Underground_POLYSET__8").RefersToRange
                        TextBox23.Text = Application.IfError(Application.Index(rng24, Application.Match(EntryNo, rng2, 0)), "")
                        
                'Plan Type
                Dim rng25 As Range
                    Set rng25 = ActiveWorkbook.Names("Plan_Type").RefersToRange
                        TextBox24.Text = Application.IfError(Application.Index(rng25, Application.Match(EntryNo, rng2, 0)), "")
                        
                'CITY
                Dim rng26 As Range
                    Set rng26 = ActiveWorkbook.Names("CITY").RefersToRange
                        TextBox25.Text = Application.IfError(Application.Index(rng26, Application.Match(EntryNo, rng2, 0)), "")
                        
                'County
                Dim rng27 As Range
                    Set rng27 = ActiveWorkbook.Names("County").RefersToRange
                        TextBox26.Text = Application.IfError(Application.Index(rng27, Application.Match(EntryNo, rng2, 0)), "")
                        
                'Jurisdiction
                Dim rng28 As Range
                    Set rng28 = ActiveWorkbook.Names("Jurisdiction").RefersToRange
                        TextBox27.Text = Application.IfError(Application.Index(rng28, Application.Match(EntryNo, rng2, 0)), "")
                        
                'Date CONSTRUCTION START
                Dim rng29 As Range
                    Set rng29 = ActiveWorkbook.Names("Date_CONSTRUCTION_START").RefersToRange
                        TextBox28.Text = Application.IfError(Application.Index(rng29, Application.Match(EntryNo, rng2, 0)), "")
                        
        End With
    End Sub
    Last edited by KentK; 10-17-2018 at 12:59 PM. Reason: Add additional observation to type/crash

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Creating INDEX MATCH MATCH formula based off text in cells
    By bbkdude in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-26-2017, 10:37 AM
  2. Replies: 4
    Last Post: 04-14-2017, 07:47 PM
  3. unable to get match property error in userform derived index match
    By alexcrofut in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-05-2015, 09:21 PM
  4. VB UserForm ComboBox List Based On Dynamic Named Range in Worksheet
    By huntethic in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-14-2015, 02:45 PM
  5. Problem with VLookup and Index Match on mixed Text and Numeric codes
    By Vaslo in forum Excel Formulas & Functions
    Replies: 28
    Last Post: 12-17-2013, 12:54 PM
  6. How to INDEX/MATCH values from SharePoint List based on excel cell value?
    By Rerock in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2012, 12:37 AM

Tags for this Thread

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