ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Add Sheets (https://www.excelbanter.com/excel-programming/363320-add-sheets.html)

Bill[_30_]

Add Sheets
 
Hello,
How I can always add a worksheet to the right of all existing, visible
worksheets in a workbook?

Thanks.

Bill



Norman Jones

Add Sheets
 
Hi Bill,

Try:

=============
Public Sub Tester()
With ActiveWorkbook
.Worksheets.Add After:=.Sheets(.Sheets.Count)
End With
End Sub
'<<=============

---
Regards,
Norman



"Bill" wrote in message
k.net...
Hello,
How I can always add a worksheet to the right of all existing, visible
worksheets in a workbook?

Thanks.

Bill




Norman Jones

Add Sheets
 
Hi Bill,

Adressing the visible criterion, try:

'=============
Public Sub Tester2()
Dim i As Long

With ActiveWorkbook
For i = .Sheets.Count To 1 Step -1
If .Sheets(i).Visible Then
.Worksheets.Add after:=.Sheets(i)
Exit For
End If
Next i
End With
End Sub
'<<=============

---
Regards,
Norman




All times are GMT +1. The time now is 04:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com