Auto-enter today's date with New Order macro button

barbd777

New Member
Joined
Mar 29, 2016
Messages
9
I need some coding help with a data entry form I've downloaded from contextures.com and customized for our company use. Sheet 1 (Input) is the data entry form, sheet 2 (RequestData) is the database sheet, sheet 3 (LookupLists) is for...Lookup Lists! Internal clients will fill out the form on sheet 1 (which is all they'll be able to see); then when they Submit the form, the data enters to sheet 2, and all the fields on sheet 1 clear for next use. I've gotten everything to work the way it's supposed to, but now I want to change/add a few functionalities and can't seem to find exactly what I'm looking for out on the web or in these forums. (I'm sure it's fairly simple if you have the coding knowledge!)


I have a "New Order" button on the data entry sheet that automatically pulls the next Order ID from a Lookup List on sheet3 and places it in the 1st field on the form. What I'd like to add to that macro is the code to automatically place today's date in the next field. I've found a lot of examples for date codes/formulas, but not sure the best way to implement/add to macro code?


IDNum is the name of the Order ID field, NextID is the field name that it pulls from on LookupLists, using the formula:
=IFERROR(MAX(RequestData!C:C)+1,0)


I guess I would need to name the date field, i.e. "TodaysDate" in order to refer to it in the code? Would it also pull from info/formula added on LookupLists?


Thanks for any help you can offer!!!


Here's the macro code currently attached to my New Order button:


Sub StartNewRecord()
Dim inputWks As Worksheet
Dim listWks As Worksheet
Dim rngClear As Range
Dim rngNext As Range
Dim rngID As Range

Set inputWks = Worksheets("Input")
Set listWks = Worksheets("LookupLists")

Set rngClear = inputWks.Range("DataEntryClear")
Set rngID = inputWks.Range("IDNum")
Set rngNext = listWks.Range("NextID")

rngClear.ClearContents
rngID.Value = rngNext.Value

inputWks.Activate
rngID.Offset(1, 0).Activate


End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Does anyone have any ideas on this date formula/issue? I really need to get this form finished! Thanks for any help offered.
 
Upvote 0
Does anyone have any ideas on this date formula/issue? I really need to get this form finished! Thanks for any help offered.

barbd777,
I'm not literate in forms, but you might get what you want by replacing this:
Code:
rngID.Offset(1, 0).Activate
with this:
Code:
rngID.Offset(1, 0)=Format(Now, "m/d/yyyy")

Perpa
 
Upvote 0
Thanks, Perpa, but I don't think I want to replace any code; I want to add the auto-date function to that particular macro (currently brings up a new order number when the button is pushed on the form...

Thanks,
barbd
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,085
Members
452,378
Latest member
Hoodzy01

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