View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default How do you update a public constant

Greg,

You can't change the value of a constant; that's why they're
called constants. Create a public variable in a regular code
module:

Public NumSheets As Long

Then in the ThisWorkbook code module

Private Sub Workbook_NewSheet(ByVal Sh As Object)
NumSheets = ThisWorkbook.Worksheets.Count
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Greg" wrote in message
om...
I need to update a public constant every time I add a sheet.

Is there a better alternative?