M
Mike K
Oh Wise Ones,
I did some searching and found some code that
counts worksheets with a particular name. I need something similar but I
need to place the count in a cell on a sheet named "Control". How would I
count the number of sheets that start with AC and place the number in cell A1
and count the number of sheets that start with NM and place them in cell A2.
As sheets are added the numbers would increment. The last part of the code
adds worksheets which I don't want to do programatically, but looks like it
would preclude code to insert the count to a cell, so I left it Please
advise.
Many Thanks,
Mike
Private Sub worksheetMaker()
Dim WB As Workbook
Dim SH As Worksheet
Dim i As Long
Dim iCtr As Long
Const sName As String = "Report"
For i = 1 To ThisWorkbook.Worksheets.Count
If Worksheets(i).Name Like sName & "*" Then
iCtr = iCtr + 1
End If
Next i
'
'If iCtr = 0 Then iCtr = 1
Set SH = Worksheets.Add(after:=Worksheets(Worksheets.Count))
SH.Name = sName & iCtr + 1
End Sub
I did some searching and found some code that
counts worksheets with a particular name. I need something similar but I
need to place the count in a cell on a sheet named "Control". How would I
count the number of sheets that start with AC and place the number in cell A1
and count the number of sheets that start with NM and place them in cell A2.
As sheets are added the numbers would increment. The last part of the code
adds worksheets which I don't want to do programatically, but looks like it
would preclude code to insert the count to a cell, so I left it Please
advise.
Many Thanks,
Mike
Private Sub worksheetMaker()
Dim WB As Workbook
Dim SH As Worksheet
Dim i As Long
Dim iCtr As Long
Const sName As String = "Report"
For i = 1 To ThisWorkbook.Worksheets.Count
If Worksheets(i).Name Like sName & "*" Then
iCtr = iCtr + 1
End If
Next i
'
'If iCtr = 0 Then iCtr = 1
Set SH = Worksheets.Add(after:=Worksheets(Worksheets.Count))
SH.Name = sName & iCtr + 1
End Sub