+ Reply to Thread
Results 1 to 2 of 2

Can I set a range variable in Public section?

  1. #1
    Registered User
    Join Date
    05-13-2008
    Posts
    14

    Can I set a range variable in Public section?

    I've looked through some of the posts on working with arrays, but I can not figure out how to incorporate the suggestions into my Userform...

    The form I've created is working, however it is quite a cumbersome code (I am happy it's working at least - it's my first attempt at VB.)

    I have several comboBoxes which are populated from data located in a separate workbook - in addition there are several textBoxes which are auto-filled dependent on the value entered in some of these comboBoxes.

    As I mentioned, the form does work however it is slow to load and also everytime a combobox is filled the workbook with the source data is opened and then closed.

    I am hoping there is a way that I can preload my data ranges on initialization and can then have them available to use throughout my form.

    I have tried different approaches in the Public portion but none of my attempts were allowed. I have attached the workbooks with the form and the source data, and below is a sample of the code that is repeated throughout the form. (There are 31 ComboBoxes using a range from the source workbook, however I believe they all will be calling from only 7 ranges of data, my code calls in the same range of cells for now just so I can see if everything is working.)


    Code for getting comboBox lists:
    Please Login or Register  to view this content.
    Code to fill-in textBoxes (ComboBoxes 1 & 3 do not auto-fill textboxes):
    Please Login or Register  to view this content.
    I would appreciate any suggestions!
    Thanks
    Bernadette
    Attached Files Attached Files

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Since ComboBox2 is populated from
    C:\DATAENTRY\EXCEL_DATA_ENTRY_WORKSHEETS\LOOKUP_DATA\LOOKUP_FIELDS.xls] Worksheets(1)A5:A21
    I would think that this will populate the textbox without having to open and close the workbook.

    Please Login or Register  to view this content.
    Similarly for combo box 4
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ 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