ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   XLA function called twice (https://www.excelbanter.com/excel-programming/316940-xla-function-called-twice.html)

Nigel[_9_]

XLA function called twice
 
I've written a few routines in an XLA to check the compare the content of
two user-selected worksheets - part of our data verifcation system. The
routine asks user to select an open workbook from a combo-box on a userForm
(list is populated before opening form). User then chooses required sheet
from a listbox on same form. This works fine when test in VBA editor by
entering function in Debug [e.g. ?GetSheetName() ]. The function is in a
class module in the XLA and is Public.

I've now assigned the function to a button on a new menu and the correct
form is displayed so the user can select sheet as required. Problem is, it
then appears for a second time and asks the user again - as if the function
is being called twice.

I've check with a very basic function (as below) and still get the 'double'
call.
===
Public Function Isvalid() As Boolean

Static intRun As Integer

intRun = intRun + 1
MsgBox "isvalid", vbOKOnly, intRun

End Function
===
This shows two succesive mesage boxes with caption of 1 then 2. New button
in Excel has call to function =IsValid()

(Win 98 + Office97)

Any ideas what's causing this ?





All times are GMT +1. The time now is 04:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com