Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Is this expected behavior?

I have several worksheets in a single workbook and I have several VBA
functions used within the workbook that use arguments from different sheets
in the workbook. When the entire workbook recalculates, it appears as if the
VBA macros run several times, even if used only once in the workbook. For
instance, one VBA function displays an error box if certain parameters are
outside of an acceptable range, which is what it is supposed to do. However,
when the workbook recalculates, the error box pops up 4-5 times saying the
arguments are incorrect, but after the boxes are closed everything is
calculated correctly. The function is working correctly, but it is as if
the function ran 4-5 times before the correct arguments where finally passed
to the function.

Is this expected behavior? How can I stop this from happening?

Thanks,

Will

-----------------------------------------------------------------------------
Less Spam Better enjoyable experience
Visit : news://spacesst.com
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Is this expected behavior?

Sounds like you are triggering a Worksheet_Change event, or some change
event. There is more than one way to fix the problem, but without
definitely tying it down to the exact cause and seeing the relevant code, I
would not pretend to offer a soloution.


"maweilian" wrote in message
...
I have several worksheets in a single workbook and I have several VBA
functions used within the workbook that use arguments from different
sheets
in the workbook. When the entire workbook recalculates, it appears as if
the
VBA macros run several times, even if used only once in the workbook. For
instance, one VBA function displays an error box if certain parameters are
outside of an acceptable range, which is what it is supposed to do.
However,
when the workbook recalculates, the error box pops up 4-5 times saying the
arguments are incorrect, but after the boxes are closed everything is
calculated correctly. The function is working correctly, but it is as if
the function ran 4-5 times before the correct arguments where finally
passed
to the function.

Is this expected behavior? How can I stop this from happening?

Thanks,

Will




-----------------------------------------------------------------------------
Less Spam Better enjoyable experience
Visit : news://spacesst.com
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Is this expected behavior?

Do you have a worksheet change event? If so add additional code to disable
and enable the events...

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False

'your code

Application.EnableEvents = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"maweilian" wrote:

I have several worksheets in a single workbook and I have several VBA
functions used within the workbook that use arguments from different sheets
in the workbook. When the entire workbook recalculates, it appears as if the
VBA macros run several times, even if used only once in the workbook. For
instance, one VBA function displays an error box if certain parameters are
outside of an acceptable range, which is what it is supposed to do. However,
when the workbook recalculates, the error box pops up 4-5 times saying the
arguments are incorrect, but after the boxes are closed everything is
calculated correctly. The function is working correctly, but it is as if
the function ran 4-5 times before the correct arguments where finally passed
to the function.

Is this expected behavior? How can I stop this from happening?

Thanks,

Will


-----------------------------------------------------------------------------
Less Spam Better enjoyable experience
Visit : news://spacesst.com
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
Expected End With.. Don Guillett Excel Programming 2 December 14th 06 07:27 PM
Expected End With.. keri Excel Programming 0 December 14th 06 05:03 PM
Expected End With.. [email protected][_2_] Excel Programming 0 December 14th 06 05:02 PM
Expected:= ??? Zurn[_7_] Excel Programming 0 September 27th 04 01:57 PM
Expected:= ??? Zurn[_6_] Excel Programming 1 September 27th 04 01:45 PM


All times are GMT +1. The time now is 08:23 PM.

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"