+ Reply to Thread
Results 1 to 6 of 6

UserForm to populate worksheet

  1. #1
    Registered User
    Join Date
    08-28-2019
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 365 Pro Plus
    Posts
    3

    UserForm to populate worksheet

    I have tried multiple types of code, viewed countless hours of Youtube clips, and other forums, and am now at wits end!

    I am trying to create a user form that will populate 13 fields (Columns) of data when the submit button is clicked. I then want the next time it is clicked to add the new data to the next row down.
    I want it to start in column B (Column A is prefilled with a serial number), and then start on Row 4 Downwards.

    I have included a number of combo boxes (which work), and a series of data validation (which work).

    No matter what i have tried i always get an error in some form.

    The Code is as follows:

    Dim sh As Worksheet
    Set sh = ThisWorkbook.Worksheets("Test List")
    Dim n As Long
    n = sh.Range("B" & Applications.Rows.Count).End(x1Up).Row

    sh.Range("B" & n + 1).Value = Me.txtTN.Value
    sh.Range("C" & n + 1).Value = Me.txtTO.Value
    sh.Range("D" & n + 1).Value = Me.txtPPOC.Value
    sh.Range("E" & n + 1).Value = Me.txtTPOC.Value
    sh.Range("F" & n + 1).Value = Me.txtAC.Value
    sh.Range("G" & n + 1).Value = Me.txtSD.Value
    sh.Range("H" & n + 1).Value = Me.txtED.Value
    sh.Range("I" & n + 1).Value = Me.cboF1.Value
    sh.Range("J" & n + 1).Value = Me.cboF2.Value
    sh.Range("K" & n + 1).Value = Me.cboF3.Value
    sh.Range("L" & n + 1).Value = Me.cboF4.Value
    sh.Range("M" & n + 1).Value = Me.txtAP.Value
    sh.Range("N" & n + 1).Value = Me.txtPJPOC.Value
    sh.Range("O" & n + 1).Value = "Proposed"

    End Sub


    2019_08_29_08_56_27_Microsoft_Visual_Basic_for_Applications_Test_Facility_Coordination_Manager.png

    Any Help with this would be greatly appreciated!!!

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: UserForm to populate worksheet

    .
    This is proven to work :

    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    08-28-2019
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 365 Pro Plus
    Posts
    3

    Re: UserForm to populate worksheet

    Logit !! Amazing, thankyou!

    Follow up, if i have two user forms, that intput to two different worksheets within the same document, are there any changes required to the above?

    Ie.
    - UserForm1 to input to worksheet "Test List"
    - UserForm 2 to input to worksheet "Asset Register"

    The command buttons and text boxes all have different names to prevent any confusion.

    The principle is the same, will add to each subsequent free row starting from cell B4.

    Again, thanks in advance.

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: UserForm to populate worksheet

    .
    Perhaps the easiest method for you would be to copy this first macro and paste it into the second userform.

    Make the first form only accessible from the sheet it will write to. Make the second form only accessible from "Test List"

    Make the second form only accessible from "Asset Register".

    The macro is written so it "writes" to the activesheet only. So long as the user has opened the userform while
    the appropriate sheet is displayed ... you'll be ok.

    There are other means of accomplishing what you want but will require a change in the macro code.

  5. #5
    Registered User
    Join Date
    08-28-2019
    Location
    Melbourne, Australia
    MS-Off Ver
    Office 365 Pro Plus
    Posts
    3

    Re: UserForm to populate worksheet

    Logit, now as i dont have any coding experience, i see this could be accomplished in two ways, which of these two would work:
    - specify the worksheet with: set ws = Worksheets("Test Sheet") or ("Asset Register") as appropriate, no other coding required....?
    or
    - following the activation of the Sub: Activate.Worksheets("Test Sheet") or ("Asset Register") as appropriate....?

    thoughts?

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,009

    Re: UserForm to populate worksheet

    .
    Please Login or Register  to view this content.
    Change "ActiveSheet" to the specific sheet name.

    Again, to make it easier for you, create one macro for the TEST SHEET form, and another macro for the ASSET REGISTER form.


    It would look like :

    Set ws = Sheets("Test Sheet")

    or

    Set ws = Sheets("Asset Register")

+ 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. Populate new row in table from a form (not userform) on another worksheet
    By joeystraw in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 12-01-2018, 10:59 AM
  2. [SOLVED] Userform calls other userform, then populate worksheet
    By Lehoi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-03-2016, 06:50 PM
  3. Possible to use a Userform to populate cells on worksheet like a database?
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-05-2015, 01:11 PM
  4. [SOLVED] Populate Userform text box with command button in worksheet
    By STU22 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-19-2014, 11:32 PM
  5. UserForm to populate multiple rows in a Worksheet
    By clapforthewolfman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-05-2013, 01:11 PM
  6. Creating a database on a worksheet to populate a userform
    By bclacquer in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-11-2010, 04:53 PM
  7. How do I get a UserForm to populate the next empty row in a worksheet?
    By JustinMAS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2008, 02:43 AM

Tags for this Thread

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