Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Default date in a UserForm box

I have UserForm3 that has a single box for the user to enter the
date. I would like this box to have the current date in there by
default, and the user can change it if needed.

When the user clicks the OK button, this date will be copied to a range
named Current_Date. I've already designed the form, with a text box,
and the OK button. I know how to get the input to Current_Date once the
user clicks OK. But, I need the default date to show up in the box when
it comes up.

I looked around in the text box properties, and didn't see where I
could set this up. Would code be written in a sub within UserForm3 to
handle this?

Also, I want to make sure the format of the date that would be entered
in the text box can only be mm/dd/yy.

As always, I appreciate any help anyone can offer.

J.O.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Default date in a UserForm box

Put it in the userform initialize event:

Private Sub UserForm_Initialize()

Text1 = Format(Date, "mm/dd/yy")

End Sub

RBS

"excelnut1954" wrote in message
ups.com...
I have UserForm3 that has a single box for the user to enter the
date. I would like this box to have the current date in there by
default, and the user can change it if needed.

When the user clicks the OK button, this date will be copied to a range
named Current_Date. I've already designed the form, with a text box,
and the OK button. I know how to get the input to Current_Date once the
user clicks OK. But, I need the default date to show up in the box when
it comes up.

I looked around in the text box properties, and didn't see where I
could set this up. Would code be written in a sub within UserForm3 to
handle this?

Also, I want to make sure the format of the date that would be entered
in the text box can only be mm/dd/yy.

As always, I appreciate any help anyone can offer.

J.O.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Default date in a UserForm box

"excelnut1954" skrev i melding
ups.com...
I have UserForm3 that has a single box for the user to enter the
date. I would like this box to have the current date in there by
default, and the user can change it if needed.


Textbox1.Text = Format(Date, "mm/dd/yy")

I looked around in the text box properties, and didn't see where I
could set this up. Would code be written in a sub within UserForm3 to
handle this?


Yes, in the form's Initialize event, or in the code that shows the form,
like

UserForm3.Textbox1.Text = Format(Date, "mm/dd/yy")
UserForm3.Show

Also, I want to make sure the format of the date that would be entered
in the text box can only be mm/dd/yy.


So you want to throw away perfectly valid date entries because the separator
is not what you planned, or the month is spelled, or the poor soul provided
a four digit year instead of just two ? Don't do it, people will hate your
application and you would too if you were them.

HTH. Best wishes Harald


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Default date in a UserForm box

Thanks for the input. The reason I want the format that way I explained
is because this will be shown in a cell, which will be part of a report
that will print out each day. I want that to look the same each day.
Besides, these people aren't smart enough to know they should hate me.
Thanks again.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Default date in a UserForm box

If you say so. But if your approach were more like "is it possible to enter
a date in any valid format and have it automatically formatted as mm/dd/yy
in print ?" then your software would be better.

Best wishes Harald

"excelnut1954" skrev i melding
oups.com...
Thanks for the input. The reason I want the format that way I explained
is because this will be shown in a cell, which will be part of a report
that will print out each day. I want that to look the same each day.
Besides, these people aren't smart enough to know they should hate me.
Thanks again.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Default date in a UserForm box

Ok, I see what you're saying. That makes sense. Thanks for the
followup. I appreaciate your input.

J.O.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Default date in a UserForm box

Thanks Harald.
Ok. I see what you're saying. I agree. Translate the user input to the
desired format to be printed. That makes much more sense.

So, here's what I'm ultimately trying to do:
The user enters the date, or accepts the default date (which I have set
up already). When the user hits OK, this date is then entered into the
range name Current_Date.
I have that part done, and it works ok. It's adjusting the date format
as it is entered into that range.

Ok... Now, what I need help with is adding the code that will do a
Save-As, and use that date as part of the name. However, I want a
prefix to the date. Example: if the date entered into the range is
12/27/05, then I want the file name to be Staging List 12-27-05.xls

I've previously been helped with doing a Save-As, doing a similar thing
with a different workbook, but with the NOW date from the computer
clock. The difference now is that there are times when this file will
be created after missing a couple days of enteries. So, the actual
current date the file will be save as may not be today. Today might be
the 27th, but they might be working on data from the 23rd. So, even
though it may be the 27th, they might be saving a file Staging List
12-23-05

So, that's why I want the macro to read the range name Current_Date to
get the date part of the new file name that will be saved. Hope that
makes sense.
Here's the code I was given before that only deals with using NOW to
get the date part of the file name.

ActiveWorkbook.SaveAs _
Filename:="Staging List " & Format(Now, "mm-dd-yy") & ".xls", _
FileFormat:=xlWorkbookNormal

I tried playing around with this today, and couldn't find a way to
replace Now with the range name Current_Date. Something in the nature
of
Filename:="Staging List " & Format(Current_Date, "mm-dd-yy") &
".xls", _

I've tried adding quotes, parenthesis, etc. No luck.
Hope you can help.

Thanks,
J.O.
Oh, I entered this problem as a new topic this morning. But, I don't
think this group was working right. I never saw it posted, and the
latest postings were from the 26th. So, if it should ever pop up as a
new topic..... sorry for the redundancy.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Default date in a UserForm box

You could try something like:

with activeworkbook
.SaveAs _
Filename:="Staging List " _
& Format(.worksheets("whatsheetname").range("Current _date").value, _
"mm-dd-yy") & ".xls", _
FileFormat:=xlWorkbookNormal
end with







excelnut1954 wrote:

Thanks Harald.
Ok. I see what you're saying. I agree. Translate the user input to the
desired format to be printed. That makes much more sense.

So, here's what I'm ultimately trying to do:
The user enters the date, or accepts the default date (which I have set
up already). When the user hits OK, this date is then entered into the
range name Current_Date.
I have that part done, and it works ok. It's adjusting the date format
as it is entered into that range.

Ok... Now, what I need help with is adding the code that will do a
Save-As, and use that date as part of the name. However, I want a
prefix to the date. Example: if the date entered into the range is
12/27/05, then I want the file name to be Staging List 12-27-05.xls

I've previously been helped with doing a Save-As, doing a similar thing
with a different workbook, but with the NOW date from the computer
clock. The difference now is that there are times when this file will
be created after missing a couple days of enteries. So, the actual
current date the file will be save as may not be today. Today might be
the 27th, but they might be working on data from the 23rd. So, even
though it may be the 27th, they might be saving a file Staging List
12-23-05

So, that's why I want the macro to read the range name Current_Date to
get the date part of the new file name that will be saved. Hope that
makes sense.
Here's the code I was given before that only deals with using NOW to
get the date part of the file name.

ActiveWorkbook.SaveAs _
Filename:="Staging List " & Format(Now, "mm-dd-yy") & ".xls", _
FileFormat:=xlWorkbookNormal

I tried playing around with this today, and couldn't find a way to
replace Now with the range name Current_Date. Something in the nature
of
Filename:="Staging List " & Format(Current_Date, "mm-dd-yy") &
".xls", _

I've tried adding quotes, parenthesis, etc. No luck.
Hope you can help.

Thanks,
J.O.
Oh, I entered this problem as a new topic this morning. But, I don't
think this group was working right. I never saw it posted, and the
latest postings were from the 26th. So, if it should ever pop up as a
new topic..... sorry for the redundancy.


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Default date in a UserForm box

You may want to try a calendar control:

Ron de Bruin has some tips/links at:
http://www.rondebruin.nl/calendar.htm

(or even 3 separate controls to select the month/day/year--just to avoid
ambiguity.)

excelnut1954 wrote:

I have UserForm3 that has a single box for the user to enter the
date. I would like this box to have the current date in there by
default, and the user can change it if needed.

When the user clicks the OK button, this date will be copied to a range
named Current_Date. I've already designed the form, with a text box,
and the OK button. I know how to get the input to Current_Date once the
user clicks OK. But, I need the default date to show up in the box when
it comes up.

I looked around in the text box properties, and didn't see where I
could set this up. Would code be written in a sub within UserForm3 to
handle this?

Also, I want to make sure the format of the date that would be entered
in the text box can only be mm/dd/yy.

As always, I appreciate any help anyone can offer.

J.O.


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default value of a List Box on a UserForm SailFL Excel Programming 1 August 19th 05 11:11 AM
Userform Yes - No Default Moe Excel Discussion (Misc queries) 0 May 26th 05 11:30 PM
Excel Default date for date format smurphy123 Excel Discussion (Misc queries) 3 January 23rd 05 09:39 PM
Date in userform being saved as general not date which affects sor Michael Malinsky[_3_] Excel Programming 0 July 28th 04 06:58 PM
Userform to select start date and end date Johnny B. Excel Programming 0 November 28th 03 05:56 PM


All times are GMT +1. The time now is 12:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"