Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2007

Tip: Looking for answers? Try searching our database.

adding tabs and naming them automatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
timmulla - 23 Jan 2007 03:46 GMT
Can anyone help me with code that can automatically creates a new tab with
the click of a commandButton.

I would like the code to loop through column A (starting in A2) and when it
finds a letter "X" in a row, it will automatically create a new tab and name
it with the accompanying text in column C.

Any help would be appreciated.

Signature

Regards,

timmulla

Doug Glancy - 23 Jan 2007 04:35 GMT
timmulla,

Here's some code to get you started at least:

Sub add_sheets
Dim last_row As Long
Dim cell As Range

With ActiveSheet
   last_row = .Range("A" & Rows.Count).End(xlUp).Row
   For Each cell In .Range("A2:A" & last_row)
       If UCase(cell.Value) = "X" Then
           ThisWorkbook.Worksheets.Add
after:=Worksheets(ThisWorkbook.Worksheets.Count)
           ActiveSheet.Name = .Range("C" & cell.Row).Value
       End If
   Next cell
End With
End Sub

hth,

Doug

> Can anyone help me with code that can automatically creates a new tab with
> the click of a commandButton.
[quoted text clipped - 6 lines]
>
> Any help would be appreciated.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.