View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Start value listbox

I put a couple of listboxes on a small userform and used this code:

Option Explicit
Private Sub UserForm_Initialize()
Dim dCtr As Long
Dim StartDate As Date

StartDate = Date

For dCtr = StartDate To DateSerial(Year(StartDate), 12, 31)
Me.ListBox1.AddItem Format(dCtr, "mm/dd/yyyy dddd")
Me.ListBox2.AddItem Format(dCtr, "mm/dd/yyyy dddd")
Next dCtr

End Sub



Henk wrote:

This is the code :

With BlockDay

.BlockDayStartDate.Clear
.BlockDayEndDate.Clear
Today = Sheets("ResAlloqBase").Range("TodaysDate").Value
For x = 1 To 366
DayNumber = Weekday(Today)
Select Case DayNumber
Case Is = 1
TodaysDay = "Sunday"
Case Is = 2
TodaysDay = "Monday"
Case Is = 3
TodaysDay = "Tuesday"
Case Is = 4
TodaysDay = "Wednesday"
Case Is = 5
TodaysDay = "Thursday"
Case Is = 6
TodaysDay = "Friday"
Case Is = 7
TodaysDay = "Saturday"
End Select

.BlockDayStartDate.AddItem (Today & " " & TodaysDay)
.BlockDayEndDate.AddItem (Today & " " & TodaysDay)

Today = Today + 1

If Month(Today) = 12 And Day(Today) = 31 Then
x = 365
End If

Next x

.BlockDayStartDate.ListIndex = 0
.BlockDayEndDate.ListIndex = 0
.BlockDayMondays.Value = True
.BlockDayTuesdays.Value = True
.BlockDayWednesdays.Value = True
.BlockDayThursdays.Value = True
.BlockDayFridays.Value = True
.BlockDaySaturdays.Value = True
.BlockDaySundays.Value = True

.BlockDayBlockDay.Value = True

MsgBox(.BlockDayStartDate & " " & .BlocDayEndDate)

.Show

End With

"JLGWhiz" wrote:

It helps to post the relavent code.

"Henk" wrote:

On a form I have 2 (as far as I can see exactly the same) ListBoxes. I fill
both ListBoxes using .AddItem with dates from today up to December 31 of this
year. For both ListBoxes I set the .ListIndex to 0. When I display the values
of both the ListBoxes in a MsgBox, I only see one (the second) value. Anyone
any idea what can be the cause of this?

I tried to force the ListBox to have a value with .LisBox.Value = , but that
did not help.

Many thanks in advance.



--

Dave Peterson