Event handler...

bahllr

Board Regular
Joined
May 7, 2009
Messages
62
I am looking for some code that will populate a number of items when a certain cell is selected in excel. I know how to set up all the code for populating cells based on the initial selection (drop down box with 3 choices).....I just don't know how to have the code operate automatically when the a choice is selected from the drop down box (cell b1).

Any ideas would be much appreciated!
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Hi,

You'll want the worksheet's change event handler for this.

If you right click on the worksheet's tab and choose View Code, the VBE will open with the worksheet's class module active. You can then paste in this code as a starting template:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 
     'check that B1 is the cell that was changed
     If Not Intersect(Target.Cells(1), Range("B1")) Is Nothing Then
     
          'your code in here
        
          
     End If
     
End Sub


Hope that helps...
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top