MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 30th, 2004, 08:36 PM   #1
dmcgimpsey
 
Join Date: Mar 2004
Location: NYC
Posts: 193
Default Listbox1

Hi There, great resource here - I am new, and trying to develop a very simple application, the question may be very trivial to most of you.

What I desire is a listbox (drop down list) on an Excel worksheet that executes a VB macro. The macro can be anything, but in my case, it will direct the person who makes the selection to a specific worksheet.

here is what I have so far ...


--------------------------------------
Private Sub ListBox1_Click()

End Sub
--------------------------------------


I either need a selection that allows me to drop a text message, and then runs a macro, or ...

goes directly to a spreadsheet (ie: via path and filename)

I appreciate your help and keep up the good work, sorry for posting such a trivial question.

Regards
dmcgimpsey is offline   Reply With Quote
Old Apr 12th, 2004, 08:54 AM   #2
HalfAce
MrExcel MVP
 
Join Date: Apr 2003
Location: Alaska
Posts: 7,332
Default Re: Listbox1

Howdy,
No such thing as trivial questions...just some that are easier to solve than others.
Here's an example of one way to do what (I think) you've asked.
For the listbox's input range I used D1:D11.
Then in D1 I entered Sheet 1, D2 = Sheet 2, D3 = Sheet 3, etc. down
to D11 = Sheet 11.
Then I used C1 as the Cell Link for the listbox.
Now, for the code. Right click on the listbox and choose Assign Macro > New (or Edit) and paste this in there.
Code:
Sub ListBox1_Change()
Dim x As Integer
x = [C1].Value
MsgBox "You have chosen to go to sheet " & x
Sheets(x).Select
End Sub
This gives an example of the message box and going directly to the sheet that was chosen from the listbox. (If you don't want the messagebox, just delete that line out.)
This give you any ideas?
Dan
__________________
XP & '03
Vista & '07
HalfAce is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 05:11 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.