Call Application.Volatile(True) NOT WORKING

F

FARAZ QURESHI

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?
 
T

T. Valko

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top