Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Problem with ComboBox, dynamic range and change event

Hi,

The Change event of the ComboBox is triggered twice when modifying ANOTHER
absolutely non-related workbook.
I'm using Excel 2002 SP3.

Steps to reproduce:
I created a new workbook, filled range A1:A6 with a,b,c,d,e,f.
Then I created a dynamic range named MyList =OFFSET(Sheet1!$A$1,0,0,6,1)
I added a ComboBox from the Control Toolbox (not Forms) and filled the
ListFillRange with "MyList".

The ComboBox has the following code:

Private Sub ComboBox1_Change()
Debug.Print "ComboBox1_Change()"
End Sub

Then I created a second (empty) workbook.
when I enter something in a cell, the ComboBox_Change() event of the first
workbook fires twice (I can see that in the immediate window).

Both workbooks have nothing to do with each other whatsoever. They only
happen to be open at the same time.

Why is this and how can I prevent this?

Thanks.
-=Wim=-
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Problem with ComboBox, dynamic range and change event

Then I created a dynamic range named MyList =OFFSET(Sheet1!$A$1,0,0,6,1)

I'd guess this is happeneing because OFFSET is a volitile function. Every
time a calculation occurs OFFSET recalcs. So your defined name is recalced
and the combo box takes that as a change event. You might have to live with
this if you want to use OFFSET.

--
Jim
"Wim SKW" wrote in message
...
| Hi,
|
| The Change event of the ComboBox is triggered twice when modifying ANOTHER
| absolutely non-related workbook.
| I'm using Excel 2002 SP3.
|
| Steps to reproduce:
| I created a new workbook, filled range A1:A6 with a,b,c,d,e,f.
| Then I created a dynamic range named MyList =OFFSET(Sheet1!$A$1,0,0,6,1)
| I added a ComboBox from the Control Toolbox (not Forms) and filled the
| ListFillRange with "MyList".
|
| The ComboBox has the following code:
|
| Private Sub ComboBox1_Change()
| Debug.Print "ComboBox1_Change()"
| End Sub
|
| Then I created a second (empty) workbook.
| when I enter something in a cell, the ComboBox_Change() event of the first
| workbook fires twice (I can see that in the immediate window).
|
| Both workbooks have nothing to do with each other whatsoever. They only
| happen to be open at the same time.
|
| Why is this and how can I prevent this?
|
| Thanks.
| -=Wim=-


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Problem with ComboBox, dynamic range and change event

Thank you Jim.

Then I think I have to use a static variable in the Change event code to
track the previous value of the ComboBox to see whether it is a "real" change
or not, and exit out of the sub in case it isn't.

Thanks
-=Wim=-

"Jim Rech" wrote:

Then I created a dynamic range named MyList =OFFSET(Sheet1!$A$1,0,0,6,1)


I'd guess this is happeneing because OFFSET is a volitile function. Every
time a calculation occurs OFFSET recalcs. So your defined name is recalced
and the combo box takes that as a change event. You might have to live with
this if you want to use OFFSET.

--
Jim


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
Change event for comboBox cmpcwil2[_17_] Excel Programming 4 May 4th 06 03:01 PM
Combobox change event only by UI Excelerate-nl Excel Programming 0 May 2nd 06 04:05 PM
MsgBox in Enter event causes combobox not to run Change event Richard Excel Programming 0 March 6th 06 02:52 PM
Combobox on change event Matt Jensen Excel Programming 4 December 29th 04 04:37 PM
combobox change event scrabtree23[_2_] Excel Programming 3 October 20th 03 05:56 PM


All times are GMT +1. The time now is 05:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"