Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you update a public constant
I need to update a public constant every time I add a sheet.
Is there a better alternative? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you update a public constant
Or just use
ThisWorkbook.Worksheets.Count directly. Just a thought. -- Regards, Tom Ogilvy "Chip Pearson" wrote in message ... 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? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you update a public constant
"Chip Pearson" wrote in message ...
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? Thanks Chip, I am curious to know why the body of the code needs to be in the ThisWorkbook code module. Chip, what other circumstances would this be required, and why would it used in the ThisWorkbook code module? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you update a public constant
See Chip Pearson's page on Events
http://www.cpearson.com/excel/events.htm Basically the creation of a new sheet causes this procedure to run. Workbook Level events are maintained in the ThisWorkbook module. -- Regards, Tom Ogilvy "Greg" wrote in message om... "Chip Pearson" wrote in message ... 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? Thanks Chip, I am curious to know why the body of the code needs to be in the ThisWorkbook code module. Chip, what other circumstances would this be required, and why would it used in the ThisWorkbook code module? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Constant loan payments vs. constant payments of principal | Excel Worksheet Functions | |||
public sub | Excel Programming | |||
Public constant in many workbooks | Excel Programming | |||
Public Sub Help | Excel Programming | |||
A constant update | Excel Programming |