Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 172
Default Default Value in a list box

I have a list box in cell A8. It's a list box created using data validation.
The values are all dates. How do I get it to populate a default date when
opening the file?
The list of values is dates for every Monday so I want it to default to the
current week's Monday. For example if today was 9/12/07 I would want it to be
9/10/07 when the file is opened. How would I make this happen?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,480
Default Default Value in a list box

Hi

Try
=TODAY()-WEEKDAY(TODAY())+2

--
Regards
Roger Govier



"Secret Squirrel" wrote in
message ...
I have a list box in cell A8. It's a list box created using data
validation.
The values are all dates. How do I get it to populate a default date when
opening the file?
The list of values is dates for every Monday so I want it to default to
the
current week's Monday. For example if today was 9/12/07 I would want it to
be
9/10/07 when the file is opened. How would I make this happen?



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 172
Default Default Value in a list box

Thanks. That should work but how do I put that into VBA code? I think that's
where it needs to go to populate the default of the list box. Correct?

"Roger Govier" wrote:

Hi

Try
=TODAY()-WEEKDAY(TODAY())+2

--
Regards
Roger Govier



"Secret Squirrel" wrote in
message ...
I have a list box in cell A8. It's a list box created using data
validation.
The values are all dates. How do I get it to populate a default date when
opening the file?
The list of values is dates for every Monday so I want it to default to
the
current week's Monday. For example if today was 9/12/07 I would want it to
be
9/10/07 when the file is opened. How would I make this happen?




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Default Value in a list box

You can use something like:

Dim myDate As Date
myDate = Date - Weekday(Date) + 2
MsgBox myDate



Secret Squirrel wrote:

Thanks. That should work but how do I put that into VBA code? I think that's
where it needs to go to populate the default of the list box. Correct?

"Roger Govier" wrote:

Hi

Try
=TODAY()-WEEKDAY(TODAY())+2

--
Regards
Roger Govier



"Secret Squirrel" wrote in
message ...
I have a list box in cell A8. It's a list box created using data
validation.
The values are all dates. How do I get it to populate a default date when
opening the file?
The list of values is dates for every Monday so I want it to default to
the
current week's Monday. For example if today was 9/12/07 I would want it to
be
9/10/07 when the file is opened. How would I make this happen?





--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 172
Default Default Value in a list box

Hi Dave,
Thanks for the response.
How would I point that code to my list box on my worksheet so it will set
that as the default date when the file is opened?

"Dave Peterson" wrote:

You can use something like:

Dim myDate As Date
myDate = Date - Weekday(Date) + 2
MsgBox myDate



Secret Squirrel wrote:

Thanks. That should work but how do I put that into VBA code? I think that's
where it needs to go to populate the default of the list box. Correct?

"Roger Govier" wrote:

Hi

Try
=TODAY()-WEEKDAY(TODAY())+2

--
Regards
Roger Govier



"Secret Squirrel" wrote in
message ...
I have a list box in cell A8. It's a list box created using data
validation.
The values are all dates. How do I get it to populate a default date when
opening the file?
The list of values is dates for every Monday so I want it to default to
the
current week's Monday. For example if today was 9/12/07 I would want it to
be
9/10/07 when the file is opened. How would I make this happen?




--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Default Value in a list box

If you're using data|validation for that cell, you can just plop that value into
that cell:

Option Explicit
Sub Auto_Open()
Dim myDate As Date
myDate = Date - Weekday(Date) + 2

with thisworkbook.worksheets("Sheet9999").range("x999")
.numberformat = "mmmm dd, yyyy"
.value = mydate
end with

end sub

Untested. Watch for typos!

Secret Squirrel wrote:

Hi Dave,
Thanks for the response.
How would I point that code to my list box on my worksheet so it will set
that as the default date when the file is opened?

"Dave Peterson" wrote:

You can use something like:

Dim myDate As Date
myDate = Date - Weekday(Date) + 2
MsgBox myDate



Secret Squirrel wrote:

Thanks. That should work but how do I put that into VBA code? I think that's
where it needs to go to populate the default of the list box. Correct?

"Roger Govier" wrote:

Hi

Try
=TODAY()-WEEKDAY(TODAY())+2

--
Regards
Roger Govier



"Secret Squirrel" wrote in
message ...
I have a list box in cell A8. It's a list box created using data
validation.
The values are all dates. How do I get it to populate a default date when
opening the file?
The list of values is dates for every Monday so I want it to default to
the
current week's Monday. For example if today was 9/12/07 I would want it to
be
9/10/07 when the file is opened. How would I make this happen?




--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 172
Default Default Value in a list box

No typos. I tried it but nothing. I put the code in the VBA window behind
that sheet, correct? Am I missing something else?

"Dave Peterson" wrote:

If you're using data|validation for that cell, you can just plop that value into
that cell:

Option Explicit
Sub Auto_Open()
Dim myDate As Date
myDate = Date - Weekday(Date) + 2

with thisworkbook.worksheets("Sheet9999").range("x999")
.numberformat = "mmmm dd, yyyy"
.value = mydate
end with

end sub

Untested. Watch for typos!

Secret Squirrel wrote:

Hi Dave,
Thanks for the response.
How would I point that code to my list box on my worksheet so it will set
that as the default date when the file is opened?

"Dave Peterson" wrote:

You can use something like:

Dim myDate As Date
myDate = Date - Weekday(Date) + 2
MsgBox myDate



Secret Squirrel wrote:

Thanks. That should work but how do I put that into VBA code? I think that's
where it needs to go to populate the default of the list box. Correct?

"Roger Govier" wrote:

Hi

Try
=TODAY()-WEEKDAY(TODAY())+2

--
Regards
Roger Govier



"Secret Squirrel" wrote in
message ...
I have a list box in cell A8. It's a list box created using data
validation.
The values are all dates. How do I get it to populate a default date when
opening the file?
The list of values is dates for every Monday so I want it to default to
the
current week's Monday. For example if today was 9/12/07 I would want it to
be
9/10/07 when the file is opened. How would I make this happen?




--

Dave Peterson


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Default Value in a list box

I assumed that you wanted to populate that cell when you opened the workbook.
Is that ok?

If it is ok, then this code goes in a general module.

If it's not ok, when should that cell be populated?

And remember to change the name of the worksheet and the address of the cell,
too.

Secret Squirrel wrote:

No typos. I tried it but nothing. I put the code in the VBA window behind
that sheet, correct? Am I missing something else?

"Dave Peterson" wrote:

If you're using data|validation for that cell, you can just plop that value into
that cell:

Option Explicit
Sub Auto_Open()
Dim myDate As Date
myDate = Date - Weekday(Date) + 2

with thisworkbook.worksheets("Sheet9999").range("x999")
.numberformat = "mmmm dd, yyyy"
.value = mydate
end with

end sub

Untested. Watch for typos!

Secret Squirrel wrote:

Hi Dave,
Thanks for the response.
How would I point that code to my list box on my worksheet so it will set
that as the default date when the file is opened?

"Dave Peterson" wrote:

You can use something like:

Dim myDate As Date
myDate = Date - Weekday(Date) + 2
MsgBox myDate



Secret Squirrel wrote:

Thanks. That should work but how do I put that into VBA code? I think that's
where it needs to go to populate the default of the list box. Correct?

"Roger Govier" wrote:

Hi

Try
=TODAY()-WEEKDAY(TODAY())+2

--
Regards
Roger Govier



"Secret Squirrel" wrote in
message ...
I have a list box in cell A8. It's a list box created using data
validation.
The values are all dates. How do I get it to populate a default date when
opening the file?
The list of values is dates for every Monday so I want it to default to
the
current week's Monday. For example if today was 9/12/07 I would want it to
be
9/10/07 when the file is opened. How would I make this happen?




--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 172
Default Default Value in a list box

I didn't realize I had to put it into a general module. It works now.
Thanks for your help Dave!

"Dave Peterson" wrote:

I assumed that you wanted to populate that cell when you opened the workbook.
Is that ok?

If it is ok, then this code goes in a general module.

If it's not ok, when should that cell be populated?

And remember to change the name of the worksheet and the address of the cell,
too.

Secret Squirrel wrote:

No typos. I tried it but nothing. I put the code in the VBA window behind
that sheet, correct? Am I missing something else?

"Dave Peterson" wrote:

If you're using data|validation for that cell, you can just plop that value into
that cell:

Option Explicit
Sub Auto_Open()
Dim myDate As Date
myDate = Date - Weekday(Date) + 2

with thisworkbook.worksheets("Sheet9999").range("x999")
.numberformat = "mmmm dd, yyyy"
.value = mydate
end with

end sub

Untested. Watch for typos!

Secret Squirrel wrote:

Hi Dave,
Thanks for the response.
How would I point that code to my list box on my worksheet so it will set
that as the default date when the file is opened?

"Dave Peterson" wrote:

You can use something like:

Dim myDate As Date
myDate = Date - Weekday(Date) + 2
MsgBox myDate



Secret Squirrel wrote:

Thanks. That should work but how do I put that into VBA code? I think that's
where it needs to go to populate the default of the list box. Correct?

"Roger Govier" wrote:

Hi

Try
=TODAY()-WEEKDAY(TODAY())+2

--
Regards
Roger Govier



"Secret Squirrel" wrote in
message ...
I have a list box in cell A8. It's a list box created using data
validation.
The values are all dates. How do I get it to populate a default date when
opening the file?
The list of values is dates for every Monday so I want it to default to
the
current week's Monday. For example if today was 9/12/07 I would want it to
be
9/10/07 when the file is opened. How would I make this happen?




--

Dave Peterson


--

Dave Peterson


--

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 to Top of Drop Down List Anita Excel Worksheet Functions 5 December 6th 06 11:22 PM
How to force a Default sort for a validation list scott56hannah Excel Discussion (Misc queries) 0 April 18th 06 03:05 AM
Default Cell Value with Validation Drop-Down List Dave H Excel Discussion (Misc queries) 0 January 30th 06 08:58 PM
List box - setting default selection Brian Excel Discussion (Misc queries) 2 January 26th 05 08:47 PM
drop down list default Justin VN Excel Worksheet Functions 2 December 21st 04 08:00 PM


All times are GMT +1. The time now is 09:11 AM.

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

About Us

"It's about Microsoft Excel"