Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Help with combo/Listbox

Hi all, i have a spreadsheet that i need to insert either a list or
combo box (Not sure which is best), so that the user can sellect a date
(Jan-07 to Dec-07)with the selected date going into "B6". I then also
have to remove the Box as the user must send the sheet by e-mail but the
date in B6 must remain. Could somebody please help me with some code to
do this ??

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Help with combo/Listbox

Hi Les -

Have you considered a calendar control ? I have yet to find a case where a
combo or listbox outperforms the calendar control for selecting dates. You
can get an outstanding version from Martin Green's web site at:

http://www.fontstuff.com/downloads/index.htm

Download Martin's "Excel Calendar Workbook.zip". Open the workbook, Export
his frmCalendar form, Import it into your workbook, and modify the form code.
Change the three instances of "ActiveCell" to "Range("B6")" to suit your
application.

After doing that, you have several options to trigger the calendar (show it
to the user). Here are two options:

Option 1: You can use Martin's right-click shortcut menu control "Insert
Date". If this is your choice, copy all of the code in Martin's ThisWorkbook
module to your ThisWorkbook module. To choose a date for cell B6, just
right-click in any cell and choose "Insert Date" from the shortcut menu.

A sub-option here is to modify Martin's code to run in the worksheet's
Activate and Deactivate event procedures. Then, the Insert Date option will
only be available from a right-click in the single worksheet.

Option 2: Add a command button to your worksheet from the Control Toolbox,
then:

a. Right-click the button, choose |Format Control...|. Click the
[Properties] tab and clear the "Print Object" checkbox and click [OK].

b. Right-click the button again, choose Properties, and modify the Caption
property to "Enter Date" (or whatever you like on the button face).

c. Right-Click the button again, choose View Code, and add the following
code in the worksheet module that opens:

Private Sub CommandButton1_Click()
frmCalendar.Show
End Sub

Repost if you'd like to take a different approach or if you need help
modifying Martin's code.

--
Jay


"Les Stout" wrote:

Hi all, i have a spreadsheet that i need to insert either a list or
combo box (Not sure which is best), so that the user can sellect a date
(Jan-07 to Dec-07)with the selected date going into "B6". I then also
have to remove the Box as the user must send the sheet by e-mail but the
date in B6 must remain. Could somebody please help me with some code to
do this ??

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Help with combo/Listbox

If you want to use a userform in VBA this is real simple code

1) on VBA insert menu select user form.
2) If toolbox doesn't show up thenlook for ICON with hammer and wrench.
3) From toolbox put listbox on the form.
4) Double click list box A new window should appear with two lines of code.
Add to this code the statementt - Userform1.hide
5) Run the code below from a module window.


Sub xyz()
Mydate = DateValue("1/1/" + CStr(Year(Date)))
Do While (1)
UserForm1.ListBox1.AddItem CStr(Mydate)
If Mydate = DateValue("12/31/" + CStr(Year(Date))) Then Exit Do
Mydate = Mydate + 1

Loop
UserForm1.Show
SelectedDate = UserForm1.ListBox1.Text
msgbox(SelectedDate)

End Sub


"Les Stout" wrote:

Hi all, i have a spreadsheet that i need to insert either a list or
combo box (Not sure which is best), so that the user can sellect a date
(Jan-07 to Dec-07)with the selected date going into "B6". I then also
have to remove the Box as the user must send the sheet by e-mail but the
date in B6 must remain. Could somebody please help me with some code to
do this ??

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 396
Default Help with combo/Listbox

Thanks all for the input, i will try all and use the most suitable...
Great weekend... :-)

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
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 or combo box and how? Kim K Excel Discussion (Misc queries) 13 March 4th 06 12:28 PM
Using a listbox/combo box to show two values matpj[_39_] Excel Programming 1 February 14th 06 10:02 AM
VBA: Creating listbox similar to the one in Pivot table (Listbox+Checkbox) modjoe23 Excel Programming 3 August 18th 05 02:35 PM
Listbox or Combo advise Greg Brow Excel Worksheet Functions 1 February 16th 05 05:43 PM
listbox.value not equal to listbox.list(listbox.listindex,0) ARB Excel Programming 0 October 22nd 03 12:46 AM


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