Send Textbox values to a cell designated by ComboBox contents which denote row and column in a table

  • Hi,


    I'll try to be brief and to the point.


    I have a user form and several target sheets.


    User form has 3 different ComboBox and 1 type of textbox. Combobox 1 is Sheet (exclude this from this question, this will be used to select different sheets to send the data to - but I'll be able to sort this code out), Combobox2 is Day and Combobox3 is month, Textbox1 will be a number.

    The sheets are essentially yearly calendars Columns (D:O) are months, Column C contains days of the month (1-31 in C17:C47).


    I would like the number in textbox to be added to the intersection of the Month and Day i.e. Jan 1 selected via the comboboxes and 10 input in Textbox, this would then appear in the intended sheet in Cell D17.


    My mind is boggled, researched for weeks, I've adapted code from a previous project which did a similar thing but was looking in 2 columns from labels on a userform rather than 1 column and 1 row using comboboxes and it was also using lastrow, which i don't think is the solution, but I've found nothing that works or any other suggestions online.


    If i'm barking up the wrong tree could you please point me in the right direction? (it might be worth noting that there are 10 of each combobox and textbox on the user form -apart from the sheet combo- to allow for multiple entries upon loading the form) Below is what I have so far - various bits have been removed where the


  • For a start you declare a variable ws but don't give it a value. It should be


    Note all variables should be declared at the top of the code.


    Code
    1. Dim ws As Worksheet
    2. If Me.ComboBox1.ListIndex < 0 Then
    3. MsgBox "you must select a name", vbCritical, "Input required"
    4. Me.ComboBox1.SetFocus
    5. Exit Sub
    6. End If
    7. Set ws = Worksheets(Me.ComboBox1.Value)

    I think this is what you are trying to do, but the code will need expanding to cover each set of controls


  • Hi Roy, I've tried this with multiple lines and to multiple sheets, it works - very much on the right track. I've just seen the new message now though. Just trying to understand what does what at the moment.


    Thank you Very much for your help!

  • Try this, I think it does what you are aiming for. I've also tidied up the rest of the code.

    Thank you for this i'll get more time tomorrow to really delve into this and set it up within the other workbooks, hopefully there shouldn't be any issues with that though!

    Thanks again