Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How to fill list box with weekdays

Hello,

I want to create a form that will have a listbox. The listbox will be filled
with a month worth of dates however only Saturdays and Sunday (not any other
day of the week).

Any ideas out there.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default How to fill list box with weekdays

Hi,

I suspect there are a lot of ideas but you need to clarify what you want:--

Your message header:-
How to fill list box with weekdays

Your message body:-
The listbox will be filled
with a month worth of dates however only Saturdays and Sunday (not any other
day of the week).

Which is it?

Mike


"Oshikawa" wrote:

Hello,

I want to create a form that will have a listbox. The listbox will be filled
with a month worth of dates however only Saturdays and Sunday (not any other
day of the week).

Any ideas out there.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How to fill list box with weekdays

Hi Mike,

I am fairly new here. Just to give you an idea it will be Something like:

Private Sub Form_Initialize()

Dim Weekdte As date

Dim DateCheck As Date

Dim i as integer




With Me

With Listbox1


For i= 1 to 30

If Format (Weekdte, "dddd mmmm yyyy") = "Saturday" or "Sunday" then

.listboxItem.Add Format (Weekdte, "dddd mmmm yyyy")
End If
Next
End With
End With


End Sub

I think this is what I have written at work can't access from home.When I
run it in work it generates an error message.

Many thanks for your help.


"Mike H" wrote:

Hi,

I suspect there are a lot of ideas but you need to clarify what you want:--

Your message header:-
How to fill list box with weekdays

Your message body:-
The listbox will be filled
with a month worth of dates however only Saturdays and Sunday (not any other
day of the week).

Which is it?

Mike


"Oshikawa" wrote:

Hello,

I want to create a form that will have a listbox. The listbox will be filled
with a month worth of dates however only Saturdays and Sunday (not any other
day of the week).

Any ideas out there.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How to fill list box with weekdays

What Mike meant was your subject line contradicted your posting's
description... Saturday and Sunday are *not* weekdays.

I have a couple of questions though. How is the month (to do this for)
determined? The end of your message makes me wonder... do you have working
code back at your office, but that same code isn't working at your home?
What versions of Excel do you have at both locations?

--
Rick (MVP - Excel)


"Oshikawa" wrote in message
...
Hi Mike,

I am fairly new here. Just to give you an idea it will be Something like:

Private Sub Form_Initialize()

Dim Weekdte As date

Dim DateCheck As Date

Dim i as integer




With Me

With Listbox1


For i= 1 to 30

If Format (Weekdte, "dddd mmmm yyyy") = "Saturday" or "Sunday" then

.listboxItem.Add Format (Weekdte, "dddd mmmm yyyy")
End If
Next
End With
End With


End Sub

I think this is what I have written at work can't access from home.When I
run it in work it generates an error message.

Many thanks for your help.


"Mike H" wrote:

Hi,

I suspect there are a lot of ideas but you need to clarify what you
want:--

Your message header:-
How to fill list box with weekdays

Your message body:-
The listbox will be filled
with a month worth of dates however only Saturdays and Sunday (not any
other
day of the week).

Which is it?

Mike


"Oshikawa" wrote:

Hello,

I want to create a form that will have a listbox. The listbox will be
filled
with a month worth of dates however only Saturdays and Sunday (not any
other
day of the week).

Any ideas out there.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How to fill list box with Weekend days (Saturday and Sunday Only)

Hi Rick,

I see, looking back at it it is true that it might be confusing, I do
apologise.

To answer the first question: the month will be the current month (from the
current day).

The version at work only works when I remove the If...then but that does not
give me the result I want. I have not tested the program at home I am just
replying from home as we are not allowed Internet in work (for security
reason). At work I use Office 2003.

Thank you very much for your time and help. It is much appreciated.





"Rick Rothstein" wrote:

What Mike meant was your subject line contradicted your posting's
description... Saturday and Sunday are *not* weekdays.

I have a couple of questions though. How is the month (to do this for)
determined? The end of your message makes me wonder... do you have working
code back at your office, but that same code isn't working at your home?
What versions of Excel do you have at both locations?

--
Rick (MVP - Excel)


"Oshikawa" wrote in message
...
Hi Mike,

I am fairly new here. Just to give you an idea it will be Something like:

Private Sub Form_Initialize()

Dim Weekdte As date

Dim DateCheck As Date

Dim i as integer




With Me

With Listbox1


For i= 1 to 30

If Format (Weekdte, "dddd mmmm yyyy") = "Saturday" or "Sunday" then

.listboxItem.Add Format (Weekdte, "dddd mmmm yyyy")
End If
Next
End With
End With


End Sub

I think this is what I have written at work can't access from home.When I
run it in work it generates an error message.

Many thanks for your help.


"Mike H" wrote:

Hi,

I suspect there are a lot of ideas but you need to clarify what you
want:--

Your message header:-
How to fill list box with weekdays

Your message body:-
The listbox will be filled
with a month worth of dates however only Saturdays and Sunday (not any
other
day of the week).

Which is it?

Mike


"Oshikawa" wrote:

Hello,

I want to create a form that will have a listbox. The listbox will be
filled
with a month worth of dates however only Saturdays and Sunday (not any
other
day of the week).

Any ideas out there.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How to fill list box with Weekend days (Saturday and Sunday Only)

Try this code...

Private Sub UserForm_Initialize()
Dim X As Long
For X = 1 To Day(DateSerial(Year(Now), Month(Now) + 1, 0))
If Weekday(DateSerial(Year(Now), Month(Now), X), vbMonday) 5 Then
ListBox1.AddItem DateSerial(Year(Now), Month(Now), X)
End If
Next
End Sub

--
Rick (MVP - Excel)


"oshikawa" wrote in message
...
Hi Rick,

I see, looking back at it it is true that it might be confusing, I do
apologise.

To answer the first question: the month will be the current month (from
the
current day).

The version at work only works when I remove the If...then but that does
not
give me the result I want. I have not tested the program at home I am just
replying from home as we are not allowed Internet in work (for security
reason). At work I use Office 2003.

Thank you very much for your time and help. It is much appreciated.





"Rick Rothstein" wrote:

What Mike meant was your subject line contradicted your posting's
description... Saturday and Sunday are *not* weekdays.

I have a couple of questions though. How is the month (to do this for)
determined? The end of your message makes me wonder... do you have
working
code back at your office, but that same code isn't working at your home?
What versions of Excel do you have at both locations?

--
Rick (MVP - Excel)


"Oshikawa" wrote in message
...
Hi Mike,

I am fairly new here. Just to give you an idea it will be Something
like:

Private Sub Form_Initialize()

Dim Weekdte As date

Dim DateCheck As Date

Dim i as integer




With Me

With Listbox1


For i= 1 to 30

If Format (Weekdte, "dddd mmmm yyyy") = "Saturday" or "Sunday" then

.listboxItem.Add Format (Weekdte, "dddd mmmm yyyy")
End If
Next
End With
End With


End Sub

I think this is what I have written at work can't access from home.When
I
run it in work it generates an error message.

Many thanks for your help.


"Mike H" wrote:

Hi,

I suspect there are a lot of ideas but you need to clarify what you
want:--

Your message header:-
How to fill list box with weekdays

Your message body:-
The listbox will be filled
with a month worth of dates however only Saturdays and Sunday (not any
other
day of the week).

Which is it?

Mike


"Oshikawa" wrote:

Hello,

I want to create a form that will have a listbox. The listbox will
be
filled
with a month worth of dates however only Saturdays and Sunday (not
any
other
day of the week).

Any ideas out there.





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
fill weekdays with date man Excel Programming 2 November 19th 08 01:43 PM
fill series by weekdays in XL 2007 Lisa Hetherington Excel Discussion (Misc queries) 1 November 9th 07 05:54 AM
Fill dates with weekdays/workdays only DJ Bjorklund Excel Worksheet Functions 1 January 18th 05 04:48 PM
Auto Fill Weekdays Only Tom Ogilvy Excel Programming 2 June 17th 04 01:31 AM
Auto Fill Weekdays Only Frank Kabel Excel Programming 0 June 16th 04 04:20 PM


All times are GMT +1. The time now is 01:22 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"