automatic entry of data into a data entry form new

Grahamscown

New Member
Joined
Feb 26, 2014
Messages
39
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. Mobile
is there a way to auto populate fields in a data entry form like seen below i would like to enter just the name and have the rego and company auto populate from a list and time . date , month and week auto populate at the same time of entry
 

Attachments

  • data entry form.JPG
    data entry form.JPG
    88.4 KB · Views: 9
You need to do that in the VB Editor, not Excel.
 
Upvote 0

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Thankyou I will update my account details when I return home later from work
 
Upvote 0
hi this is as far as i have got so far the close script works but the add script is not adding the data to the sheet the time and date buttons dont do anything at the moment as i want to try to auto populate them when the form is started
 

Attachments

  • newdata1.JPG
    newdata1.JPG
    167 KB · Views: 5
  • newdata2.JPG
    newdata2.JPG
    92 KB · Views: 5
Upvote 0
VBA Code:
VBA Code:
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("sameday")

'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 a 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.txttime.Value
  .Cells(iRow, 2).Value = Me.txtname.Value
  .Cells(iRow, 3).Value = Me.txtrego.Value
  .Cells(iRow, 4).Value = Me.txtcompany.Value
  .Cells(iRow, 5).Value = Me.txtdate.Value
  .Cells(iRow, 6).Value = Me.txtmonth.Value
  .Cells(iRow, 7).Value = Me.txtweek.Value
  '  .Protect Password:="password"
End With

'clear the data
Me.txttime.Value = ""
Me.txtname.Value = ""
Me.txtrego.Value = ""
Me.txtcompany.Value = ""
Me.txtname.Date = ""
Me.txtrego.Month = ""
Me.txtcompany.week = ""
Me.txttime.SetFocus
End Sub


 Private Sub cmdClose_Click()
  Unload Me
End Sub

Private Sub txtcompany_Change()

End Sub

Private Sub txtdate_Change()

End Sub

Private Sub txtmonth_Change()

End Sub

Private Sub txtname_Change()

End Sub

Private Sub txtrego_Change()

End Sub

Private Sub txtweek_Change()

End Sub

Private Sub UserForm_Click()

End Sub
 
Upvote 0
Ok, thanks for that.
If you add this msgbox as shown & click the button, what does the message return
Rich (BB code):
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
    SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
MsgBox iRow
'check for a date
 
Upvote 0
Ok, thanks for that.
If you add this msgbox as shown & click the button, what does the message return
Rich (BB code):
'find first empty row in database
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
    SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
MsgBox iRow
'check for a date
sorry where will i add it to the bottom or top
 
Upvote 0

Forum statistics

Threads
1,214,402
Messages
6,119,304
Members
448,886
Latest member
GBCTeacher

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