+ Reply to Thread
Results 1 to 8 of 8

getting a run time error 1004, trying to create a combobox

  1. #1
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    getting a run time error 1004, trying to create a combobox

    here is my code to initialize the form:

    Please Login or Register  to view this content.
    what am i doing wrong?

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,880

    Re: getting a run time error 1004, trying to create a combobox

    Is scope of named range set to workbook or worksheet?

    If former, try just using Rane("Names") instead of ws.Range("Names")
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: getting a run time error 1004, trying to create a combobox

    thanks CK, but i changed this one line and it's working now.

    Please Login or Register  to view this content.
    i added the ThisWorkbook to the set statement.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,880

    Re: getting a run time error 1004, trying to create a combobox

    Glad you got it solved. I actually ran some tests and scope had no impact when it's set to workbook.
    I guess, you had another workbook active when the code ran.

  5. #5
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: getting a run time error 1004, trying to create a combobox

    one quick question, im trying to create a combobox that lists two ranges, the first one is named Hours and the second is offset to that. so why isn't this working?

    Please Login or Register  to view this content.

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,880

    Re: getting a run time error 1004, trying to create a combobox

    What's the end result you are trying to achieve?

    Should both be loaded to same combobox and selected as one?

    If so do something like.
    Please Login or Register  to view this content.
    Or are you trying to do something different?

  7. #7
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: getting a run time error 1004, trying to create a combobox

    ok so that shows the combobox with both columns of text, but when i pick something off the list, then it only returns the first column in the combobox. see snapshot. how do i fix that?

    combobox1.png

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,880

    Re: getting a run time error 1004, trying to create a combobox

    That's expected behavior of Combobox. Combobox can only display value of first visible column.

    I've experimented with it before. But there really isn't direct way to show both columns.

    One method is to use caption or text box above combo box to show both.

    Another is to have 3rd column added to range concatenating 1 & 2.
    Then setting column width of 1st and 2nd to 0. Hence, showing 3rd column only.
    Please Login or Register  to view this content.
    Or use _Change event to change ColumnWidth.
    Please Login or Register  to view this content.
    Or just use listbox instead of Combobox.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. error 1004 when hide/unhide rows using activex multiple combobox
    By wnd.le in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-02-2017, 06:55 PM
  2. Run-time error '1004' when trying to create PDF
    By suetyun in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-25-2015, 05:38 AM
  3. Combobox selection / Delete row after saving in another sheet / Run-time error '1004'
    By Arvin.Amaro in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-15-2015, 07:27 PM
  4. Run Time Error 1004 when trying to create a Query Table
    By scottbass in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 01-23-2014, 08:23 PM
  5. Need to Create Error Message Box during Runtime error 1004
    By ExcelHelp2013 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-14-2013, 06:24 AM
  6. Error "run-time Error '1004': General Odbc Error
    By D4WNO77 in forum Access Tables & Databases
    Replies: 2
    Last Post: 07-16-2012, 09:55 AM
  7. 1004 Error:VB code to restrict the use of a combobox
    By bernie_bolt_sa in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-03-2008, 09:55 AM

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