Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Default value in Listbox

Hi,

I have created a Listbox in a Userform with a single
column of information containing the months in a year
(1,2,...,12).
Is it possible to set the actual month as a default value
in the Listbox?

Thanks for all answers!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Default value in Listbox

Something like:

Private Sub UserForm_Initialize()
Dim L As Long
For L = 1 To 12
ListBox1.AddItem _
StrConv(Format(DateSerial(2000, L, 1), _
"mmmm"), vbProperCase)
Next
ListBox1.ListIndex = Month(Date) - 1
End Sub

Note that a listbox's 1st entry is number 0, so that's where the -1 part
comes in. You get used to it pretty fast.
--
HTH. Best wishes Harald
Followup to newsgroup only please

"Caspar" skrev i melding
...
Hi,

I have created a Listbox in a Userform with a single
column of information containing the months in a year
(1,2,...,12).
Is it possible to set the actual month as a default value
in the Listbox?

Thanks for all answers!




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Default value in Listbox

http://www.google.com/groups?hl=en&l...096b12c&rnum=4

In the userform initialize event

ListBox1.Value = Month(Date)

HTH
Paul
--------------------------------------------------------------------------------------------------------------
Be advised to back up your WorkBook before attempting to make changes.
--------------------------------------------------------------------------------------------------------------
Hi,

I have created a Listbox in a Userform with a single
column of information containing the months in a year
(1,2,...,12).
Is it possible to set the actual month as a default value
in the Listbox?

Thanks for all answers!


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
Listbox 2 takes the value of Listbox 1 Illya Teideman Excel Discussion (Misc queries) 3 April 10th 07 03:20 PM
listbox B conditional of input in Listbox A Kim K Excel Discussion (Misc queries) 1 October 31st 06 08:27 PM
Listbox B if LIstbox A equals Kim K Excel Discussion (Misc queries) 2 October 31st 06 07:03 PM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM
Sorting ListBox results or transposing ListBox values to other cells for sorting Rob[_8_] Excel Programming 1 July 9th 03 04:35 AM


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