PC Review


Reply
Thread Tools Rate Thread

adding tabs and naming them automatically

 
 
=?Utf-8?B?dGltbXVsbGE=?=
Guest
Posts: n/a
 
      23rd Jan 2007
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.


--
Regards,

timmulla
 
Reply With Quote
 
 
 
 
Doug Glancy
Guest
Posts: n/a
 
      23rd Jan 2007
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

"timmulla" <(E-Mail Removed)> wrote in message
news:FA80634C-3946-4493-BD3C-(E-Mail Removed)...
> 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.
>
>
> --
> Regards,
>
> timmulla



 
Reply With Quote
 
Jimbo213
Guest
Posts: n/a
 
      29th Jul 2009
Doug - that's pretty clever

How can I add worksheet tabs where the names are in B1 to (last value in Row
1)

--
Thanks for your reply & assistance.
Jimbo213


"Doug Glancy" wrote:

> 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
>
> "timmulla" <(E-Mail Removed)> wrote in message
> news:FA80634C-3946-4493-BD3C-(E-Mail Removed)...
> > 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.
> >
> >
> > --
> > Regards,
> >
> > timmulla

>
>
>

 
Reply With Quote
 
Jimbo213
Guest
Posts: n/a
 
      29th Jul 2009

The values I want for tab names are in row 1, not column B.
I want to create a tab for with the values in B1, C1, D1, E1, .... X1 [for
example]

Will your proposed code do that?


--
Thanks for your reply & assistance.
Jimbo213


"stanleydgromjr" wrote:

>
> Jimbo213,
>
> Try:
>
>
> Code:
> --------------------
>
>
> Option Explicit
> Sub add_sheets()
> Dim c As Range
> With ActiveSheet
> For Each c In .Range("B1", .Range("B" & .Rows.Count).End(xlUp))
> Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = c.Value
> Next c
> End With
> End Sub
>
>
> --------------------
>
>
>
> Have a great day,
> Stan
>
>
> --
> stanleydgromjr
> ------------------------------------------------------------------------
> stanleydgromjr's Profile: http://www.thecodecage.com/forumz/member.php?userid=503
> View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=120419
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Naming Tabs HUTCH Microsoft Excel Worksheet Functions 1 3rd Sep 2009 06:11 PM
naming tabs steve Microsoft Excel Worksheet Functions 2 1st Dec 2007 08:15 PM
Naming tabs Mike Microsoft Excel Worksheet Functions 5 27th Nov 2007 05:04 PM
Naming Tabs =?Utf-8?B?ZWJybw==?= Microsoft Excel Misc 3 13th Jul 2006 11:07 PM
naming tabs Jeff Microsoft Excel Worksheet Functions 8 6th Feb 2006 04:41 AM


Features
 

Advertising
 

Newsgroups
 


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