+ Reply to Thread
Results 1 to 2 of 2

Thread: Userform - Taking data from the spreadsheet

  1. #1
    Registered User
    Join Date
    11-16-2011
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    35

    Userform - Taking data from the spreadsheet

    Hi There,

    Attached is my Spreadsheet with a very basic userform.

    The idea is simple, click on a cell in column "A" and the userform is loaded. Once the information is filled out and the "Submit button" is clicked the information well be sent to designated cells within the workbook.

    The problem I'm having is that I can't get the information to send to the same row that is selected. So for example if "A4" is selected, all the information will be sent to the appropriate columns in the same row ("B4", "C4", "D4"), and if "A8" is selected, the information would be sent to "B8, C8, D8) etc... Is this possible to do? If it is, is it then possible to pull out information already in them cells? So for example if there was already text in "C4", the text would be in the related box in the userform.
    I apologise if this is confusing. It's easier to see what I'm trying to achieve by looking at the spreadsheet.

    Thanks for any help in advance!
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & read 2007
    Posts
    15,979

    Re: Userform - Taking data from the spreadsheet

    Hello revenge4ash89,

    Here is the working code for the command button.
    
    Private Sub CommandButton1_Click()
    
        Dim iRow As Long
        Dim Rng As Range
        Dim ws As Worksheet
    
            Set ws = Worksheets("DataSource")
            Set Rng = ws.Range("A2")
    
                iRow = ws.Cells(Rows.Count, Rng.Column).End(xlUp).Row
                iRow = IIf(iRow < Rng.Row, Rng.Row, iRow + 1)
    
                ws.Cells(iRow, 1) = example1.Value
                ws.Cells(iRow, 2) = example2.Value
                ws.Cells(iRow, 3) = date1.Value
                ws.Cells(iRow, 4) = comboexample.Value
                ws.Cells(iRow, 5) = date1.Value
                ws.Cells(iRow, 6) = comboexample2.Value
                ws.Cells(iRow, 7) = example5.Value
                ws.Cells(iRow, 13) = comboexample3.Value
                ws.Cells(iRow, 16) = comboexample4.Value
                ws.Cells(iRow, 16) = comboexample5.Value
    
            Unload Me
    
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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.2.0