Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Selecting from a Validation Drop Down Box aborts macro

I am using Microsoft Excell 2003 SP1.

I have a UDF in a normal Module that reads all the worksheet names in
the active workbook and puts them into an array. A Summary worksheet
contains a formula copied to several cells in a column that uses this
UDF to list the sheet names. The formulas end in (wihout the quotes)
"&T(RAND())" to make it volatile so that it updates whenever worksheet
names are changed.

I also have a Workbook_SheetChange macro that writes data into an
adjacent cell when a target cell value is changed. I use
Application.EnableEvents=False at the beginning and
Application.EnableEvents = True at the end of the macro. The target
cell has a validation drop down list.

When the line of the macro is reached where it is supposed to write to
the adjacent cell, before the data is actually written to the cell, the
UDF is called and executes.

This is not a problem if valid data is entered into the target cell via
keyboard entry. The UDF executes and execution is returned to the
macro which then finishes normally. But if the data is selected from
the validation dropdown list, execution never returns from the UDF back
to the macro. The data never gets written to the adjacent cell and the
Application.EnableEvents remains False.

Is there anything I can do to keep the UDF from taking over the
execution of the code? The Application.EnableEvents = False does not do
it. Any other VBA statements that would do the job?

Thanks,

Larry

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Selecting from a Validation Drop Down Box aborts macro

Design the UDF not to cause an error

Public function ABC()
On error Resume Next



End Function




and

Private Sub Workbook_SheetChange( . . .

On Error goto ErrHandler
Application.EnableEvents = False



' don't write anything to jump over the
' error handler.
ErrHandler:
Application.EnableEvents = True
End Sub


wrote in message
ps.com...
I am using Microsoft Excell 2003 SP1.

I have a UDF in a normal Module that reads all the worksheet names in
the active workbook and puts them into an array. A Summary worksheet
contains a formula copied to several cells in a column that uses this
UDF to list the sheet names. The formulas end in (wihout the quotes)
"&T(RAND())" to make it volatile so that it updates whenever worksheet
names are changed.

I also have a Workbook_SheetChange macro that writes data into an
adjacent cell when a target cell value is changed. I use
Application.EnableEvents=False at the beginning and
Application.EnableEvents = True at the end of the macro. The target
cell has a validation drop down list.

When the line of the macro is reached where it is supposed to write to
the adjacent cell, before the data is actually written to the cell, the
UDF is called and executes.

This is not a problem if valid data is entered into the target cell via
keyboard entry. The UDF executes and execution is returned to the
macro which then finishes normally. But if the data is selected from
the validation dropdown list, execution never returns from the UDF back
to the macro. The data never gets written to the adjacent cell and the
Application.EnableEvents remains False.

Is there anything I can do to keep the UDF from taking over the
execution of the code? The Application.EnableEvents = False does not do
it. Any other VBA statements that would do the job?

Thanks,

Larry



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
MACRO: Selecting "Cancel" from a drop down to copy and paste entirerow to another sheet Nicole Hannington Excel Discussion (Misc queries) 1 July 20th 09 07:11 PM
MACRO: Selecting "Cancel" from a drop down to copy and paste entirerow to another sheet Nicole Hannington Excel Worksheet Functions 1 July 20th 09 06:51 PM
Running a macro when selecting an item in a drop-down list Christine Excel Discussion (Misc queries) 4 August 1st 08 08:50 PM
Selecting from a Validation Drop Down Box aborts macro Lreeder Excel Worksheet Functions 0 August 27th 05 01:41 AM
Selecting next drop down item in pivot table with a macro ??? Keilan Knight Excel Programming 2 February 22nd 05 11:30 AM


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