LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Macro/Macro interference

Excel XP & Win XP
I have a problem that Bob Phillips has been kind enough to help me with.
We're still working on it. I have narrowed it down significantly and
thought it would be helpful to post this to the whole newsgroup along with a
copy to Bob.
Below are two small procedures, one a Worksheet_Calculate macro and the
other a UDF. They both do the same thing: Count the number of cells in a
range (the same range).

Private Sub Worksheet_Calculate()
Range("D2").Value = Range("A8", Range("A" & Rows.Count).End(xlUp)).Count
End Sub

Function PupilCount() As Long
Application.Volatile
PupilCount = Range("A8", Range("A" & Rows.Count).End(xlUp)).Count
End Function


To manifest the problem, please do the following:
Open a new blank workbook (only one sheet is needed).
In Column A, starting with A8 down, fill a few cells with any text or
numbers you want.
Copy/Paste the above WorkSheet_Calculate procedure into the sheet module.
In any blank cell type =1+2 to force a calculation.
Note that cell D2 displays the cell count of Col A.
Remark-out the WorkSheet_Calculate procedure. (IMPORTANT)
Insert a regular module.
Copy the above Function into that module.
In any blank cell, type =PupilCount() and hit Enter.
The same cell count is displayed in the cell.
Clear that cell. (IMPORTANT)
UnRemark-out the WorkSheet_Calculate procedure.
Now you have both procedures active.
In any blank cell, type =PupilCount() and hit Enter.
I get the count for just a moment, then a VALUE error in the cell.
Why?

Thanks for your help. Otto


 
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 recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
dragging without interference BorisS Excel Worksheet Functions 3 May 20th 05 08:16 PM
UDF - Macro Interference Otto Moehrbach[_5_] Excel Programming 2 September 20th 03 12:23 AM


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