+ Reply to Thread
Results 1 to 11 of 11

Combobox - insert text to cells

  1. #1
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Combobox - insert text to cells

    Hi,

    I have a Combobox which lists text (time-intervals). I managed to split this text in Combobox and put It separately in two cells under, for needs of calculating time differences.

    Problem is, that I need this kind of solution for many rows(79) and columns (31), and all this Comboboxes must insert text only in cells right under them. Combobox is not positioned in cell, so I don't know how to write code that would do that, other than write a code for each Combobox alone (that would be like 2.400 times !).

    Please take a look at my sample worksheet, notice that only first "solution" (column B and C) is programmed so far. I want It to be done for both (and all afterwards), in a VBA loop maybe...

    My code so far:

    Please Login or Register  to view this content.
    Is It even possible ?

    Thanks for help !!

    Regards, Luka
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Combobox - insert text to cells

    Hi again,

    I see that nobody has any suggestions so far. I'm working now with one thing that might work, but still need help, nothing works at the moment. I came to an idea that I could link each combobox to a specific cell, and then write It's text to both cells using this in VBA. I would still ned to link cells for all comboboxes in properties, but at least code would be only one.

    My code at the moment looks like this :

    Please Login or Register  to view this content.
    Am I at least a little on right path ?
    I'm a VBA beginner, so please don't laugh
    Last edited by Lukael; 04-26-2014 at 11:11 AM.

  3. #3
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Combobox - insert text to cells

    Hi Luka,
    maybe so
    Please Login or Register  to view this content.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Combobox - insert text to cells

    Hi nilem,

    I tested your solution and It works. But I would prefer visible and docked comboboxes as I have them in my sample worksheet. Do you think that is impossible for all comboboxes ?

    I am thinking of just changing this section of your code, so that It would work for all different Comboboxes, but I don't know how to determine their position on sheets :

    Please Login or Register  to view this content.
    Thanks for response !!

  5. #5
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Karlstad, Sweden
    MS-Off Ver
    Excel 2016
    Posts
    232

    Re: Combobox - insert text to cells

    First, I'd like to say that nilems solution is very nice. That code can help me in other applications.

    In attached wkb there are 2 possible solutions if you want the comboboxes visible all the time:
    - ActiveX Controls: You must attach code to each combobox. (There is a solution to involve Classes if you only want to write the eventhandler code once. I have attached a file that I have inherited from another person. I use this code when I want to connect eventhandlers to controls in userform added during Run-Time. Code connected to button "Sheet Control Array" is the code you need to modify to fit your application.)
    - Form Controls: No VBA code is needed. You can only copy and paste the range including the combobox. You must change the Linked to Cell manually. Unfortunately.
    1. Reply to thread and inform if suggestion was helpful or not
    2. Click on the star (=Add Reputation) if you think someone helped you
    3. Mark [SOLVED] to this thread if solution was found. (On Menu "Thread Tools" > "Mark this thread as solved")

  6. #6
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Combobox - insert text to cells

    Hi Joakim N,

    I agree that nilem solution is nice and I will try to use his code for my needs. As It comes for me his solution would be o.k., but in my case end-user is not happy with It, so I have to change It.

    I looked at your solutions, and have to say that I allready did try all this, and that's why I posted a thread on this forum.

    In my case only ActiveX controls would be satisfactory, but the problem is that I have like 2400 Comboboxes on sheets, which is quite long code as you imagine.

    Form controls are of no use for me, as I need a drop-down list on start/end cells for making own entries, but also to insert a text from Comboboxes - which are commonly used time intervals (shift schedule). So, when you select a new time entry from drop/down list, a formula in start/end cells is being deleted, and then combobox text cannot be inserted again.

    But I think could be solved also for my needs, just don't know how yet

  7. #7
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Combobox - insert text to cells

    Hi again,

    what about solution sometinhg like this :

    Please Login or Register  to view this content.
    Ofcourse It's not working, but I just want comboboxes to be recognized as objects, looping through them with integer (based on a name), and assign each one the same command that nilem has allready included. How can I fix this ?
    Last edited by Lukael; 04-27-2014 at 04:52 PM.

  8. #8
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Combobox - insert text to cells

    Or maybe fixing this code, It loops through all comboboxes but cannot perform command with each one (red colour) :

    Please Login or Register  to view this content.
    I receive error "method of data member not found" in this code !!

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Combobox - insert text to cells

    Shouldn't com be comboB, or the loop variable be com?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  10. #10
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Combobox - insert text to cells

    maybe
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    02-09-2014
    Location
    Kamnik, Slovenia
    MS-Off Ver
    Excel 2010
    Posts
    693

    Re: Combobox - insert text to cells

    Hi nilem,

    that's It, I knew I was very close to solution

    I had same code allready, just that I have misstyped comboB as Norie mentioned

    But I added some minor things to It, like having It in selection change event of worksheet and to have list in start/end cells where you can enter manually your times If combobox index is 0.

    Code :


    Please Login or Register  to view this content.
    I attached final solution for those who would like to view !

    Thanks for all your help !!
    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)

Similar Threads

  1. combobox text - insert formula
    By Lukael in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-24-2014, 04:40 PM
  2. Insert text next to selected cells
    By yunesm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-19-2010, 12:01 PM
  3. Combobox to determine text for a range of cells
    By Robbyn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-26-2006, 10:25 AM
  4. [SOLVED] Compare Text/combobox values against cells in spreadsheet
    By BigPig in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-20-2006, 01:30 PM
  5. [SOLVED] insert text in a no. of cells of each sheet?
    By hally in forum Excel General
    Replies: 3
    Last Post: 05-06-2005, 12:06 PM

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