Results 1 to 10 of 10

Basic Userform to populate sheet not working

Threaded View

  1. #1
    Registered User
    Join Date
    12-07-2016
    Location
    Oregon, USA
    MS-Off Ver
    2016
    Posts
    33

    Basic Userform to populate sheet not working

    Hello all! I'm trying to create a very basic userform for data entry. I have watched tons of tutorials and found several sets of code to do this but none of them seem to work in my project. Below is some code that I've tried and I keep getting a run-time error and I cannot figure out why. Thanks for any help. The attached sheet only has 1 combo box in the userform to simplify this and I will adjust the code as I add more controls. The error seems to point to the "Set nextrow" line.

    Private Sub UpdateSheet_Click()
    Dim cNum As Integer
    Dim X As Integer
    Dim Teams As String
    Dim nextrow As Range
    Dim sht As String
    'set the variable for the sheet
    sht = TeamCombobox.Value
    'check for values
    If Me.TeamCombobox.Value = "" Then
    MsgBox "Select a sheet from the combobox and add the date"
    Exit Sub
    End If
    'change the number for the number of controls on the userform
    cNum = 1
    'add the data to the selected worksheet
    Set nextrow = Sheets(sht).Cells(Rows.Count, 3).End(xlUp).Offset(1, 0)
    For X = 1 To cNum
    nextrow = Me.Controls("Reg" & X).Value
    Set nextrow = nextrow.Offset(0, 1)
    Next
    'clear the values in the userform
    For X = 1 To cNum
    Me.Controls("Reg" & X).Value = ""
    Next
    'communicate the results
    MsgBox "The values have been sent to the " & sht & " sheet"
    End Sub
    Attached Files Attached Files
    Last edited by Betsy Simpkins; 11-08-2018 at 04:32 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Excel stops working with Userform Textbox populate
    By Sintek in forum Excel Programming / VBA / Macros
    Replies: 52
    Last Post: 05-22-2018, 10:14 AM
  2. [SOLVED] VBA to populate range with textbox.value form UserForm keyboard input not working
    By Sintek in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-07-2016, 03:12 AM
  3. Populate Excel Userform with Sheet names with double click to open the sheet ??
    By Shacker in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-08-2013, 03:54 PM
  4. Populate Excel Userform with Sheet names
    By PC in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-08-2013, 09:37 AM
  5. Populate a UserForm field with value from excel sheet
    By onmyway in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-07-2012, 04:54 AM
  6. populate userform combobox with sheet names
    By tapapad in forum Excel General
    Replies: 3
    Last Post: 11-14-2008, 03:10 AM
  7. Populate sheet from userform
    By cityfc in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-15-2006, 06:25 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