Data Entry Form

lfellows

New Member
Joined
Nov 22, 2019
Messages
35
Hi,

I'm trying to create a data entry form which will populate cells within a table on another sheet. I am aware you can use the form button but it does not have the level of customisability that I'm after.

The workbook is used to collate scrap quantities found at different stages of a process. It contains two sheets: One sheet that will contain the data entry form and the other sheet will have the table of information.

There are 20 columns that I would like to fill:

DATESTART TIMEEND TIMEOPBATCHTYPESTART QTYPROCESS 1PROCESS 2PROCESS 3PROCESS 4PROCESS 5PROCESS 6PROCESS 7PROCESS 8PROCESS 9PROCESS 10PROCESS 11PROCESS 12END QTY

The columns which are non-bold would be a simple manual input.

The columns which are bold, if possible I would like to be able to have a drop down list to select which process the scrap goes into i.e. if there is 10 scrapped at process 7, you would select process 7 from dropdown list and input 10

I will upload an image of the sheet if it's any help.

Thank you for any assistance. I'm not even sure if what I'm asking for is achievable.

1576148070978.png
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Rather than doing all this in a sheet, I would suggest creating a UserForm. If you're not sure how to do that have a look here.
 
Upvote 0
Hi Fluff,

thanks for the link!

I've got it working however I want to know if its possible to use data validation lists for one of the columns? if so, how?
I want to use data validation on my 7th column, the "Process" column.
here is my code:

Code:
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("TableOfData")
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
    SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'check for a date
If Trim(Me.txtDate.Value) = "" Then
Me.txtDate.SetFocus
MsgBox "Please enter the date"
Exit Sub
End If
'copy the data to the database
'use protect and unprotect lines,
' with your password
' if worksheet is protected
With ws
' .Unprotect Password:="password"
.Cells(iRow, 1).Value = Me.txtDate.Value
.Cells(iRow, 2).Value = Me.txtStartTime.Value
.Cells(iRow, 3).Value = Me.txtEndTime.Value
.Cells(iRow, 4).Value = Me.txtOperator.Value
.Cells(iRow, 5).Value = Me.txtBatchNumber.Value
.Cells(iRow, 6).Value = Me.txtType.Value
.Cells(iRow, 7).Value = Me.txtProcess.Value
.Cells(iRow, 8).Value = Me.txtStartQuantity.Value
.Cells(iRow, 9).Value = Me.txtScrapQuantity.Value
' .Protect Password:="password"
End With
'clear the data
Me.txtDate.Value = ""
Me.txtStartTime.Value = ""
Me.txtEndTime.Value = ""
Me.txtOperator.Value = ""
Me.txtBatchNumber.Value = ""
Me.txtType.Value = ""
Me.txtProcess.Value = ""
Me.txtStartQuantity.Value = ""
Me.txtScrapQuantity.Value = ""
Me.txtDate.SetFocus
End Sub

Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the Close Form button!"
End If

End Sub
 
Last edited by a moderator:
Upvote 0
Do you mean have data validation in the sheet, or in the userform?
 
Upvote 0
In the Userform. A drop down list to select the process.

Apologies for the confusion I'm rather new to this.
 
Upvote 0
Ok, delete the "Process" textbox and replace it with a ComboBox.
Add this code to the userform module
Rich (BB code):
Private Sub UserForm_Initialize()
    Me.cboProcess.List = Evaluate("row(1:12)")
End Sub
and change you command button code to
Rich (BB code):
Private Sub cmdAdd_Click()
    Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("TableOfData")
    'find first empty row in database
    iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
        SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
    'check for a date
    If Trim(Me.txtDate.Value) = "" Then
        Me.txtDate.SetFocus
        MsgBox "Please enter the date"
        Exit Sub
    End If
    If Me.cboProcess.ListIndex = -1 Then
        MsgBox "please select a process"
        Exit Sub
    End If
    
    'copy the data to the database
    'use protect and unprotect lines,
    ' with your password
    ' if worksheet is protected
    With ws
        ' .Unprotect Password:="password"
        .Cells(iRow, 1).Value = Me.txtDate.Value
        .Cells(iRow, 2).Value = Me.txtStartTime.Value
        .Cells(iRow, 3).Value = Me.txtEndTime.Value
        .Cells(iRow, 4).Value = Me.txtOperator.Value
        .Cells(iRow, 5).Value = Me.txtBatchNumber.Value
        .Cells(iRow, 6).Value = Me.txtType.Value
        .Cells(iRow, 7).Value = Me.txtStartQuantity.Value
        .Cells(iRow, 7 + Val(Me.cboProcess.Value)).Value = Me.txtScrapQuantity.Value
        ' .Protect Password:="password"
    End With
    
    'clear the data
    Me.txtDate.Value = ""
    Me.txtStartTime.Value = ""
    Me.txtEndTime.Value = ""
    Me.txtOperator.Value = ""
    Me.txtBatchNumber.Value = ""
    Me.txtType.Value = ""
    Me.txtProcess.Value = ""
    Me.txtStartQuantity.Value = ""
    Me.txtScrapQuantity.Value = ""
    Me.txtDate.SetFocus
End Sub
Change the name of the combo in red to suit.
 
Upvote 0
Not that I know much about code but the new code compared to the old code looks slightly different, is this right?

With ws
' .Unprotect Password:="password"
.Cells(iRow, 1).Value = Me.txtDate.Value
.Cells(iRow, 2).Value = Me.txtStartTime.Value
.Cells(iRow, 3).Value = Me.txtEndTime.Value
.Cells(iRow, 4).Value = Me.txtOperator.Value
.Cells(iRow, 5).Value = Me.txtBatchNumber.Value
.Cells(iRow, 6).Value = Me.txtType.Value
.Cells(iRow, 7).Value = Me.txtStartQuantity.Value .Cells(iRow, 7 + Val(Me.cboProcess.Value)).Value = Me.txtScrapQuantity.Value
' .Protect Password:="password"
End With


With ws
' .Unprotect Password:="password"
.Cells(iRow, 1).Value = Me.txtDate.Value
.Cells(iRow, 2).Value = Me.txtStartTime.Value
.Cells(iRow, 3).Value = Me.txtEndTime.Value
.Cells(iRow, 4).Value = Me.txtOperator.Value
.Cells(iRow, 5).Value = Me.txtBatchNumber.Value
.Cells(iRow, 6).Value = Me.txtType.Value
.Cells(iRow, 7).Value = Me.txtProcess.Value
.Cells(iRow, 8).Value = Me.txtStartQuantity.Value
.Cells(iRow, 9).Value = Me.txtScrapQuantity.Value
' .Protect Password:="password"
End With
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,935
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top