Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-06-2016, 11:40 AM
barbd777 barbd777 is offline Auto-enter today's date with New Order Macro button? Windows 7 32bit Auto-enter today's date with New Order Macro button? Office 2010 32bit
Novice
Auto-enter today's date with New Order Macro button?
 
Join Date: Apr 2016
Posts: 4
barbd777 is on a distinguished road
Default Auto-enter today's date with New Order Macro button?

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.

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"? 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 that 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
Reply With Quote
  #2  
Old 04-08-2016, 09:16 AM
OfficeNewb OfficeNewb is offline Auto-enter today's date with New Order Macro button? Windows 10 Auto-enter today's date with New Order Macro button? Office 2013
Novice
 
Join Date: Nov 2015
Posts: 4
OfficeNewb is on a distinguished road
Default

Hello -

In order to insert the current date into a cell you could use:

Code:
 
ActiveCell.Value = Date
For your specific scenario you will first need to make reference to the cell where you want to place the current date. For example, if the date field is called "cDate" then your code would look like this.

Code:
 
cDate.value = Date
Reply With Quote
  #3  
Old 04-08-2016, 09:33 AM
barbd777 barbd777 is offline Auto-enter today's date with New Order Macro button? Windows 7 32bit Auto-enter today's date with New Order Macro button? Office 2010 32bit
Novice
Auto-enter today's date with New Order Macro button?
 
Join Date: Apr 2016
Posts: 4
barbd777 is on a distinguished road
Default

Thanks for the suggestion, OfficeNewb! I have named that field TodaysDate, so it would be:

Code:
TodaysDate.value = Date
Yes? Where I'm getting hung up is where to add the code in my existing macro. Or can I tie it to that specific cell so that it auto-populates with the date??? (I am such a noob! Not really an Excel user, but tasked with creating this user form!!!)

Thanks much for your assistance,
barbd
Reply With Quote
  #4  
Old 04-08-2016, 09:38 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Auto-enter today's date with New Order Macro button? Windows 7 64bit Auto-enter today's date with New Order Macro button? Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,779
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

@barbd777

Please wrap code with code tags - Thank you
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #5  
Old 04-08-2016, 09:48 AM
barbd777 barbd777 is offline Auto-enter today's date with New Order Macro button? Windows 7 32bit Auto-enter today's date with New Order Macro button? Office 2010 32bit
Novice
Auto-enter today's date with New Order Macro button?
 
Join Date: Apr 2016
Posts: 4
barbd777 is on a distinguished road
Default

Sorry about that, Pecoflyer--(I really am a newbie!) Do I need to edit my original post? (Not seeing any Edit button?)

Thanks,
barbd
Reply With Quote
  #6  
Old 04-08-2016, 09:56 AM
OfficeNewb OfficeNewb is offline Auto-enter today's date with New Order Macro button? Windows 10 Auto-enter today's date with New Order Macro button? Office 2013
Novice
 
Join Date: Nov 2015
Posts: 4
OfficeNewb is on a distinguished road
Default

Quote:
Yes? Where I'm getting hung up is where to add the code in my existing macro. Or can I tie it to that specific cell so that it auto-populates with the date??? (I am such a noob! Not really an Excel user, but tasked with creating this user form!!!)
The place where you want the date to show, is it a cell on worksheet or a control on the userform? Can you provide a screenshot? Thanks
Reply With Quote
  #7  
Old 04-08-2016, 01:53 PM
barbd777 barbd777 is offline Auto-enter today's date with New Order Macro button? Windows 7 32bit Auto-enter today's date with New Order Macro button? Office 2010 32bit
Novice
Auto-enter today's date with New Order Macro button?
 
Join Date: Apr 2016
Posts: 4
barbd777 is on a distinguished road
Thumbs up Solved!

Thank you, OfficeNewb, for your replies. It is a cell on a worksheet that is set up as an order entry form.

I did find my answer on another forum:
http://www.excelforum.com/excel-prog...ro-button.html

Code:
Sub StartNewRecord()
   Dim inputWks As Worksheet
   Dim listWks As Worksheet
   Dim rngClear As Range
   Dim rngNext As Range
   Dim rngID As Range
   Dim rngOrderDate 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")
   Set rngOrderDate = inputWks.Range("TodaysDate")
   
   rngClear.ClearContents
   rngID.Value = rngNext.Value
   rngOrderDate = Date
   
   inputWks.Activate
   rngID.Offset(1, 0).Activate

End Sub
Props to 6StringJazzer!
Reply With Quote
Reply

Tags
date, macro automatic



Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto-enter today's date with New Order Macro button? Show date instead of Today, Yesterday . . BrazzellMarketing Outlook 7 08-15-2013 07:32 AM
Auto-enter today's date with New Order Macro button? Today's Date Function freschij Excel 3 02-11-2011 10:21 AM
Creating an Auto-Calc'd Date? Today+7 Days? SoCalTelephone Word 0 10-06-2010 10:27 AM
new appointment date always reverts back to today's date msills Outlook 0 08-24-2007 08:57 AM
Auto-enter today's date with New Order Macro button? Imported message date change to today's date promark Outlook 1 12-23-2005 07:21 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:38 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft