Results 1 to 4 of 4
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ComboBox Challenged (XP)

    I have attached a sample file which depicts my challenge; it's two-fold. Upon AUTO_OPEN pass to a variable the activefile.name and then when ComboBox1 is clicked, a message box appears displaying the activeworkbook.name. The second part of the challenge is when anything is typed in a cell including a cell clearcontents (by depressing the DEL key the message box appears.

    It should be simple enough but is clear as mud.

    Thanks,
    John
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ComboBox Challenged (XP)

    Don't use the On Click event of the combo box for this. Why would you want to display the file name when somebody clicks on a combo box?

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ComboBox Challenged (XP)

    Hans,

    My orignal file passes the oWB to the code attached to a ComboBox so that the code would appear as: Workbooks(oWB).Sheets("MySheet").Range("A2"). It is necessary to depict which workbook the sheet/range is in. If you recall from the threads above the code for the ComboBox was being run when a new workbook was opened by code. This will eliminate Excel's confusion as to which workbook the code is associated with.

    It would appear that Excel's order of precedence is to test the code in the ComboBoxes prior to running any code in AUTO_OPEN. The sample file attached was to demonstrate that as well as the other challenge of typing something in a cell and having the message box popup.

    I hope this explanation helps, if not please let me know and I will reword it.

    Regards,
    John

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: ComboBox Challenged (XP)

    You can inspect ActiveWorkbook at any moment, there is no need to set something when the workbook is opened. Alternatively, you can use ThisWorkbook - that will always refer to the workbook running the code, whether it is active or not.

Posting Permissions

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