View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
T. Valko T. Valko is offline
external usenet poster
 
Posts: 15,768
Default Call Application.Volatile(True) NOT WORKING

Inserting a sheet does not trigger a calculation. Deleting a sheet *does*
trigger a calculation.

If the sheets are inserted with code, after you insert them add a line of
code to calculate.

--
Biff
Microsoft Excel MVP


"FARAZ QURESHI" wrote in message
...
I have a custom macro as below to count sheets in the current book:

Public Function CNTSH(Optional ByVal bIncludeChartSheets As Boolean =
True)
As Integer
Call Application.Volatile(True)
If bIncludeChartSheets = True Then
CNTSH = Application.ActiveWorkbook.Sheets.Count
Else
CNTSH = Application.ActiveWorkbook.Worksheets.Count
End If
End Function

Upon adding a new sheet the result doesn't change unless I press:
F9; or
F2 & Enter;
Reenter the complete format.

Why? Application.Volatile has been set to true?
--

Best Regards,
FARAZ A. QURESHI