Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Event of the dropdownbox in a cell

I have made a dropdonwbox in a cell by defining a validation list to the
cell.
Is it possible to catch the event when the user select an item in the
dropdownbox? I want to fill up other cells in the same row when it happens.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Event of the dropdownbox in a cell

I figure out that I can use a formula in the other cells but I do need a
macro as the user may accidentally delete the contents of these cells and
the formula will also be deleted.
So I need to capture this event handler and then call a
function/procedure/macro to do a look up and fetch the values and fill in
these other cells.

"Man Utd" wrote in message
...
I have made a dropdonwbox in a cell by defining a validation list to the
cell.
Is it possible to catch the event when the user select an item in the
dropdownbox? I want to fill up other cells in the same row when it
happens.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Event of the dropdownbox in a cell

the change_event of the worksheet will be triggered
when you change / select in data validation dropdown


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Man Utd wrote :

I figure out that I can use a formula in the other cells but I do
need a macro as the user may accidentally delete the contents of
these cells and the formula will also be deleted.
So I need to capture this event handler and then call a
function/procedure/macro to do a look up and fetch the values and
fill in these other cells.

"Man Utd" wrote in message
...
I have made a dropdonwbox in a cell by defining a validation list
to the cell.
Is it possible to catch the event when the user select an item in
the dropdownbox? I want to fill up other cells in the same row when
it happens.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default Event of the dropdownbox in a cell

You can't capture the event of clicking the item in the dropdown box per se
(except perhaps with complex API code) but, for most versions of Excel past
xl97, you can capture the worksheet change event that is triggered when a
selection is made. You need to disable and reenable events in your code else
the act of populating the cells will cause a loop. Code example:

Private Sub Worksheet_Change(ByVal Target As Range)
With Application
.EnableEvents = False
With Target
Cells(.Row, Columns.Count). _
End(xlToLeft)(1, 2) = .Value
End With
.EnableEvents = True
End With
End Sub

Regards,
Greg

"Man Utd" wrote:

I have made a dropdonwbox in a cell by defining a validation list to the
cell.
Is it possible to catch the event when the user select an item in the
dropdownbox? I want to fill up other cells in the same row when it happens.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default Event of the dropdownbox in a cell

My code example should restrict the cell to the one with the dropdown box.
Assuming cell C2:
Private Sub Worksheet_Change(ByVal Target As Range)
With Application
.EnableEvents = False
With Target
If .Address = "$C$2" Then _
Cells(.Row, Columns.Count). _
End(xlToLeft)(1, 2) = .Value
End With
.EnableEvents = True
End With
End Sub

"Man Utd" wrote:

I have made a dropdonwbox in a cell by defining a validation list to the
cell.
Is it possible to catch the event when the user select an item in the
dropdownbox? I want to fill up other cells in the same row when it happens.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default Event of the dropdownbox in a cell

'To incrementally populate the cells to the right with the selections:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
Set c = ActiveCell
If Not Target.Address = c.Address Then Exit Sub
Application.EnableEvents = False
Cells(c.Row, Columns.Count).End(xlToLeft)(1, 2) = c.Value
Application.EnableEvents = True
End Sub

'To change all cells to the right with the current selection:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, c As Range
Set c = ActiveCell
If Not Target.Address = c.Address Then Exit Sub
Application.EnableEvents = False
Set rng = Range(c(1, 2), Cells(c.Row, Columns.Count))
rng.Value = c.Value
Application.EnableEvents = True
End Sub

Regards,
Greg

"Man Utd" wrote:

I figure out that I can use a formula in the other cells but I do need a
macro as the user may accidentally delete the contents of these cells and
the formula will also be deleted.
So I need to capture this event handler and then call a
function/procedure/macro to do a look up and fetch the values and fill in
these other cells.

"Man Utd" wrote in message
...
I have made a dropdonwbox in a cell by defining a validation list to the
cell.
Is it possible to catch the event when the user select an item in the
dropdownbox? I want to fill up other cells in the same row when it
happens.




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
Master details in 2 dropdownbox Man Utd Excel Programming 1 June 15th 05 05:40 AM
Dropdownbox Debra Dalgleish Excel Programming 1 August 6th 04 09:13 AM
Dropdownbox Alvin Hansen[_2_] Excel Programming 0 August 5th 04 07:55 AM
Dropdownbox Frank Kabel Excel Programming 1 August 5th 04 07:27 AM
Dropdownbox libby Excel Programming 0 August 4th 04 10:11 PM


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