+ Reply to Thread
Results 1 to 5 of 5

User Form Data Entry

  1. #1
    Registered User
    Join Date
    03-07-2015
    Location
    pigeon forge tn
    MS-Off Ver
    2010
    Posts
    14

    User Form Data Entry

    I have a Code for my user form and it works somewhat. Right now when you input the data and just stays on the same row rather than dropping to the next one.
    I need it to input the data from the userform to the next available row. I know its prob somthing simple but im just missin it. Also if i can get it to fill in data by columns it would work better. Where my Heading would be in A Column and My data entry would start on B Column and Continue that way instead of going down.

    Here is my Code:

    Private Sub cmdSubmit_Click()
    Dim RowCount As Long
    Dim ctl As Control

    'Check User Input
    If Me.txtApparatus.Value = "" Then
    MsgBox "Please enter Apparatus.", vbExclamation, "Form Error"
    Me.txtApparatus.SetFocus
    Exit Sub
    End If
    If Me.txtReporter.Value = "" Then
    MsgBox "Please enter your Name.", vbExclamation, "Form Error"
    Me.txtReporter.SetFocus
    Exit Sub
    End If
    If Me.txtDate1.Value = "" Then
    MsgBox "Please enter a Date.", vbExclamation, "Form Error"
    Me.txtDate1.SetFocus
    Exit Sub
    End If
    If Not IsDate(Me.txtDate1.Value) Then
    MsgBox "The Date box must contain a date.", vbExclamation, "Form Error"
    Me.txtDate1.SetFocus
    Exit Sub
    End If
    'Write data to worksheet

    RowCount = Worksheets("MaintLog").Range("a2").CurrentRegion.Rows.Count
    With Worksheets("MaintLog").Range("A2")
    .Offset(RowCount, 0).Value = Me.txtApparatus.Value
    .Offset(RowCount, 1).Value = Me.txtAppearance.Value
    .Offset(RowCount, 2).Value = Me.cboPriority1.Value
    .Offset(RowCount, 3).Value = Me.txtMechanical.Value
    .Offset(RowCount, 4).Value = Me.cboPriority2.Value
    .Offset(RowCount, 5).Value = Me.txtElectrical.Value
    .Offset(RowCount, 6).Value = Me.cboPriority3.Value
    .Offset(RowCount, 7).Value = Me.txtReporter.Value
    .Offset(RowCount, 8).Value = DateValue(Me.txtDate1.Value)
    .Offset(RowCount, 9).Value = Format(Now, "dd/mm/yyyy hh:nn:ss")

    End With

    'Clear the form
    For Each ctl In Me.Controls
    If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
    ctl.Value = ""

    Unload Me
    End If
    Next ctl
    End Sub

  2. #2
    Forum Contributor
    Join Date
    06-11-2014
    MS-Off Ver
    Office 2003, 2007 & 2010
    Posts
    119

    Re: User Form Data Entry

    For the first part of your question, simply add + 1 to the rowcount= line:

    Please Login or Register  to view this content.
    Not sure what you mean by your second request, could you please produce an example workbook of your expected output etc?

  3. #3
    Registered User
    Join Date
    03-07-2015
    Location
    pigeon forge tn
    MS-Off Ver
    2010
    Posts
    14

    Re: User Form Data Entry

    Instead of going down by row with data i want to be able to go by column.

    It Fills in Data Now Like This:

    A B C D

    1 Name Description Date ETC..


    2 Data Entry Data Entry Data Entry Data Entry


    3 Data Entry Data Entry Data Entry Data Entry


    4


    I want to be able to do this:

    A B C D

    1 Name Data Entry Data Entry


    2 Description Data Entry Data Entry


    3 Date Data Entry Data Entry

    4 Etc.... Data Entry Data Entry

  4. #4
    Forum Contributor
    Join Date
    06-11-2014
    MS-Off Ver
    Office 2003, 2007 & 2010
    Posts
    119

    Re: User Form Data Entry

    Yes this is possible although not recommended as you will run out of columns a lot quicker than you would rows:

    Please Login or Register  to view this content.
    On mobile so I couldn't rewrite it all for you, I've just turned RowCount into a column count, this relies on there always being data in your Apparatus box, else things will get overwritten. Again, I emplore you to stick with rows as opposed to columns

  5. #5
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: User Form Data Entry

    Try this method,
    Basically you are finding the next empty row in column B then using that as the row number

    Please Login or Register  to view this content.
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

+ 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. I need to make data entry user form
    By gunatilake.dayan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-07-2014, 10:35 AM
  2. Select user form with data entry
    By itsunclebill in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-01-2010, 12:07 AM
  3. User Form for Data Entry In Excel
    By tariqnaz2005 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-10-2009, 09:40 AM
  4. Data Entry Alert in User Form
    By Kev in forum Excel General
    Replies: 7
    Last Post: 01-08-2005, 11:06 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