Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default User to choose an item from a list

Hi,

I want to offer user with a window containing names of the months in a
year seperately on each line.

The user would choose one of the 12 and press something like ok and I
want the month chosen by the user to be stored in a variable in my
code.

If I can get some skeleton code for similar situation I can try to
customise this for my requirements.

Please guide me as to how I may achieve the same.

Regards,
HP
India

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default User to choose an item from a list

Create a list of month names somewhere in your workbook, and name it
(InsertNameDefine...) say Months.

Then use Data Validation (DataValidation) with a type of list and a value
of =Months.

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"Hari" wrote in message
oups.com...
Hi,

I want to offer user with a window containing names of the months in a
year seperately on each line.

The user would choose one of the 12 and press something like ok and I
want the month chosen by the user to be stored in a variable in my
code.

If I can get some skeleton code for similar situation I can try to
customise this for my requirements.

Please guide me as to how I may achieve the same.

Regards,
HP
India



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default User to choose an item from a list

Bob,

Thanks for the response. Iam aware of this feature of Data validation
using Named ranges.

Actually am writing some code to produce some reports and in the midst
of it I need to prompt the user about the month for which the report
needs to be generated. I want to avoid user entering his options in the
workbook itself. Rather I want this to be done at run-time of the code.
Hence, my request to offer user a window and once chosen, store user's
response in a variable.

Please guide me for the same.

regards,
HP
India

Bob Phillips wrote:
Create a list of month names somewhere in your workbook, and name it
(InsertNameDefine...) say Months.

Then use Data Validation (DataValidation) with a type of list and a value
of =Months.

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"Hari" wrote in message
oups.com...
Hi,

I want to offer user with a window containing names of the months in a
year seperately on each line.

The user would choose one of the 12 and press something like ok and I
want the month chosen by the user to be stored in a variable in my
code.

If I can get some skeleton code for similar situation I can try to
customise this for my requirements.

Please guide me as to how I may achieve the same.

Regards,
HP
India


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default User to choose an item from a list

You will need to define an userform.

Here is an example: http://cjoint.com/?futKV4V1wA
NB: you must double-click a month to select it

Userform code is:

'-------------
Option Explicit

Private Sub lbMonth_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Me.Hide
End Sub

Private Sub UserForm_Initialize()
Dim iMonth As Byte
Dim aMonthArray(12, 2) As Variant
For iMonth = 1 To 12
aMonthArray(iMonth - 1, 0) = iMonth
aMonthArray(iMonth - 1, 1) = _
Format(DateSerial(0, iMonth, 1), "mmmm")
Next iMonth
lbMonth.List = aMonthArray
End Sub
'--------------

test code (your macro) is:

'-------------
Sub test()
Dim iMonth As Integer
ufSelectMonth.Show
iMonth = ufSelectMonth.lbMonth.Value
MsgBox iMonth
End Sub
'--------------
"Hari" a écrit dans le message de news:
...
Bob,

Thanks for the response. Iam aware of this feature of Data validation
using Named ranges.

Actually am writing some code to produce some reports and in the midst
of it I need to prompt the user about the month for which the report
needs to be generated. I want to avoid user entering his options in the
workbook itself. Rather I want this to be done at run-time of the code.
Hence, my request to offer user a window and once chosen, store user's
response in a variable.

Please guide me for the same.

regards,
HP
India

Bob Phillips wrote:
Create a list of month names somewhere in your workbook, and name it
(InsertNameDefine...) say Months.

Then use Data Validation (DataValidation) with a type of list and a
value
of =Months.

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"Hari" wrote in message
oups.com...
Hi,

I want to offer user with a window containing names of the months in a
year seperately on each line.

The user would choose one of the 12 and press something like ok and I
want the month chosen by the user to be stored in a variable in my
code.

If I can get some skeleton code for similar situation I can try to
customise this for my requirements.

Please guide me as to how I may achieve the same.

Regards,
HP
India




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default User to choose an item from a list

Ardus,

Thanks for your code. It works really great.

I hope to use this technique for my other requirements as well.

Regards,
HP
India



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
drop down data want to choose more than one item for cell FranW Excel Worksheet Functions 1 February 26th 10 08:44 PM
How can I choose more than one item from list in a form in Excel? Jolly Excel Worksheet Functions 7 July 14th 08 06:28 PM
Can I choose more than one item in the page field area? trainer07 Excel Discussion (Misc queries) 1 April 19th 07 10:22 AM
Macro to allow user to "choose" a month from a list Ronny Hamida Excel Programming 4 April 5th 06 10:15 PM
ask user to choose Sam Excel Programming 0 September 23rd 03 01:43 PM


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

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"