Results 1 to 5 of 5

Add data to row depending on combobox

Threaded View

  1. #1
    Registered User
    Join Date
    02-21-2014
    Location
    Denmark
    MS-Off Ver
    Excel 2013
    Posts
    6

    Add data to row depending on combobox

    Hi there, I hope someone can help me with this, I'm pretty new to this VBA coding and I have been having trouble with this.

    Basically I have a column filled with names (A) that the combobox is filled with, I then have a text based inputbox and a submit button.
    Right now the submit button transfers the data from the inputbox to the same row depending on the combobox choice and edits the existing text which is fine.

    However I also want the data to be submitted to another sheet where the data is not edited but added.

    Example: I choose James from combobox and writes 10 in the inputbox, the submit button will then edit the existing value on the "Data Edit" sheet on the row James
    and add the value to the row James on the "Data Add sheet".

    This is the edit code, I basically just need some pointers as to how to add data to blank cells in corresponding rows according to combobox selection.

    Public myRow As Long
    Private Sub ComboBox1_Click()
        myRow = Application.Match(Me.ComboBox1.Value, Sheets("DataEdit").Range("A:A"), 0)
        Me.TextBox1.Value = Application.Index(Sheets("DataEdit").Columns(2), myRow)
    End Sub
    
    Private Sub CommandButton1_Click()
     ' Stores the name for search value
    NameOrig = TextBox1.Value
     
     'Finds the name from the dropdown and deletes it
    With Worksheets("DataEdit").Range("A:A")
        .Cells(myRow, 2).Value = TextBox1.Value
        ' etc.
    End With
    Unload Me
    End Sub
    
    Private Sub UserForm_Initialize()
        For Each c In Worksheets("DataEdit").Range("A2", Range("A65000").End(xlUp))
            Me.ComboBox1.AddItem c.Value
        Next c
    End Sub
    Thanks beforehand, from a VBA noob
    Attached Files Attached Files
    Last edited by p.noia; 02-21-2014 at 06:30 AM. Reason: Clarified

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Depending combobox + filtering /VBA
    By gmonlline in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-07-2014, 04:09 PM
  2. [SOLVED] Search on sheets depending on combobox value
    By puuts in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-15-2013, 08:58 AM
  3. Add value to cell depending on combobox value !
    By Petter120 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-09-2012, 02:45 PM
  4. List Box Depending on Combobox
    By excelkeechak in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-30-2009, 08:01 AM
  5. Filling two ComboBox Depending On Another ComboBox and ...
    By iscar_marius in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 01-27-2009, 08:08 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