VBA with Dates

fekish

New Member
Joined
Sep 2, 2011
Messages
7
Hello,

i am not very literate in VBA but through google i managed to make a database style worksheet for my sister to record inventory stock.

What i cannot figure out now is the selection of date.
When we click NEW STOCK then there are some fields to complete. Is there a way to have also a field with now date to be automatically added?

For now the person should select from the drop down list the date, but i dont mind either if the date is automatically put there, or if the date is automatically put the other sheet where the data is stored.
If in the end the date is selected from the list, is there a way to show the actual date on the form after is selected, rather than just numbers?

The code for now is like this:

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

' Chexk user input
If Me.Quantity.Value = "" Then
MsgBox "Please enter the quantity if shoes", vbExclamation, "Staff Expenses"
Me.Quantity.SetFocus
Exit Sub
End If

' Write data to worksheet
RowCount = Worksheets("Sale").Range("B1").CurrentRegion.Rows.Count
With Worksheets("Sale").Range("B1")
.Offset(RowCount, 1).Value = Me.Quantity.Value
.Offset(RowCount, 2).Value = Me.Shoes.Value
.Offset(RowCount, 3).Value = Me.Size.Value
.Offset(RowCount, 4).Value = Me.Number.Value
.Offset(RowCount, 5).Value = Me.DateNow.Value

End With

' Clear the form
For Each ctl In Me.Controls
If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
ctl.Value = ""
ElseIf TypeName(ctl) = "CheckBox" Then
ctl.Value = False
End If
Next ctl
End Sub
 
I think some sample data would be useful.:)
 
Upvote 0

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,224,617
Messages
6,179,914
Members
452,949
Latest member
beartooth91

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