automatic entry of data into a data entry form new

Grahamscown

New Member
Joined
Feb 26, 2014
Messages
35
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: 7

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,562
Office Version
  1. 365
Platform
  1. Windows
You need to do that in the VB Editor, not Excel.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Grahamscown

New Member
Joined
Feb 26, 2014
Messages
35
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. Mobile
Thankyou I will update my account details when I return home later from work
 

Grahamscown

New Member
Joined
Feb 26, 2014
Messages
35
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. Mobile

ADVERTISEMENT

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: 2
  • newdata2.JPG
    newdata2.JPG
    92 KB · Views: 3

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,562
Office Version
  1. 365
Platform
  1. Windows
Can you post your actual code rather than just an image. How to Post Your VBA Code
Also do you get any errors when you click the button?
 

Grahamscown

New Member
Joined
Feb 26, 2014
Messages
35
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. Mobile
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
62,562
Office Version
  1. 365
Platform
  1. Windows
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
 

Grahamscown

New Member
Joined
Feb 26, 2014
Messages
35
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. Mobile
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
 

Forum statistics

Threads
1,141,704
Messages
5,707,970
Members
421,538
Latest member
Krisco

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
Top