|
-
Oct 25th, 2003, 12:22 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] Excel VBA: Attach a macro to a picklist?
hey yers.
I have a picklist, which i am gathering from a named range, using the data validation -> list = named range ETC.
now, i am guessing it prolly wont b possible, but im still hoping to give it a shot:
can i assign a macro to run every time this list item changes?
when the list changes, i wish to fetch some data from another sheet, to re-populate my sheet (this i know how to do), but i dont know how to initiate the macro when it changes.
would i need to use the combobox of the forms? or is it possible from the normal drop down?.
if i need to use the combobox it isnt too much of a bother, EXCEPT: how do i refer to a combo box item that is selected via the VBA ide in the code?.... (so i can place the value in a cell, and not just the list index (which the LINK TO CELL option does) so i can easily use it in all the formulae in my workbook ETC...
it would be alot more helpful if i didnt have to use the combo box tho..... ne one wanna help me wid dis?
Tnx.
-
Oct 27th, 2003, 08:51 PM
#2
Fanatic Member
In the IDE, in the Project Explorer pane, under your VBA Project, under Microsoft Excel Objects, double-click on the Sheet that has the cell wth the validation. This opens the Worksheet module. In the drop-down at the top of the module, change (General) to Worksheet. In the drop-down next to it, select the Change event. This fires whenever the workbook is changed. The Change event passes a Target range that represents the cell (or range of cells) that was changed. For example, if your validation is in cell D6:
In a worksheet:
VB Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$6" Then
MsgBox "You changed cell D6 to " & Target.Value
End If
End Sub
-
Oct 28th, 2003, 03:12 AM
#3
Thread Starter
Frenzied Member
cool.
thanks, thats got it - just gotta fill in ma code to fetch the new data when thats changed and im "done" with the coding (for now) 
Taa.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|