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 / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Creating new worksheets in a workbook....with a twist

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
londar - 12 Jul 2006 17:01 GMT
I am currently trying to create somthing, I dont even know if excel i
capable of doing it however.

Basically I have a main page (Sheet 1) with a list in Column A wit
building sites. Currently it goes from A10-32. Now each of thes
currently has another worksheet within the workbook attached to it, an
the information in the according row is displayed in that workbook.

Is there a way in excel to create somthing so that when I add a nam
into cell A33 that it automatically creates a new Worksheet with
title of what is written in that cell? Only the Column A would be abl
to do this no other columns.

*Sorry for the dbl post....have NO idea which forum this would appl
to*
Bob Phillips - 12 Jul 2006 17:20 GMT
Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A:A"
Dim sh As Worksheet

   On Error GoTo ws_exit:
   Application.EnableEvents = False
   If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
       With Target
           If .Value <> "" Then
               On Error Resume Next
               Set sh = Worksheets(.Value)
               On Error GoTo 0
               If sh Is Nothing Then
                   Worksheets.Add(after:=Worksheets(Worksheets.Count)).Name
= .Value
                   Me.Activate
               End If
           End If
       End With
   End If

ws_exit:
   Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

Signature

HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

> I am currently trying to create somthing, I dont even know if excel is
> capable of doing it however.
[quoted text clipped - 11 lines]
> *Sorry for the dbl post....have NO idea which forum this would apply
> to**
londar - 12 Jul 2006 18:06 GMT
thanks,

the '=.Value'  area is giving me a compile error however?

Signature

londar

Bob Phillips - 12 Jul 2006 18:24 GMT
wrap-around

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A:A"
Dim sh As Worksheet

   On Error GoTo ws_exit:
   Application.EnableEvents = False
   If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
       With Target
           If .Value <> "" Then
               On Error Resume Next
               Set sh = Worksheets(.Value)
               On Error GoTo 0
               If sh Is Nothing Then
                   Worksheets.Add(after:=Worksheets(Worksheets.Count)) _
                       .Name = .Value
                   Me.Activate
               End If
           End If
       End With
   End If

ws_exit:
   Application.EnableEvents = True
End Sub

Signature

HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

> thanks,
>
> the '=.Value'  area is giving me a compile error however?
londar - 12 Jul 2006 18:51 GMT
it is still giving me an error right here:

Worksheets.Add(after:=Worksheets(Worksheets.Count)) _
.Name = .Value

I am correct in just copying and pasting what you typed out into the
code section correct.

I really appreciate the help

Signature

londar

Bob Phillips - 12 Jul 2006 20:14 GMT
It works fine for me. Presumably, you are typing the value into column A?

Signature

HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

> it is still giving me an error right here:
>
[quoted text clipped - 5 lines]
>
> I really appreciate the help
londar - 12 Jul 2006 21:26 GMT
correct it is going into column A.

I copy and pasted exactly what you typed.

Signature

londar

Pete_UK - 12 Jul 2006 23:25 GMT
Try splitting the line at a different point, i.e.:

Worksheets.Add(after:=Worksheets(Worksheets.Count)).Name _
= .Value

Hope this helps.

Pete

> correct it is going into column A.
>
[quoted text clipped - 5 lines]
> londar's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=32970
> View this thread: http://www.excelforum.com/showthread.php?threadid=560743
Bob Phillips - 12 Jul 2006 23:49 GMT
Did you copy and paste or type it? I believe Excel forum sometimes loses the
dots, so check the code here http://tinyurl.com/kckne

Signature

HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

> correct it is going into column A.
>
> I copy and pasted exactly what you typed.
londar - 17 Jul 2006 21:43 GMT
ya i have copied that and still nothing.  
Just to make sure I am doing this right.  I have the sheet where thes
locations I am adding located on SHeet1.

I am right clicking the Sheet1 tab and clicking view code.  I am the
pasting that text as it appears into this area.

is this right or am I missing a big step causing these issues?

Thanks

Bob Phillips Wrote:
> Did you copy and paste or type it? I believe Excel forum sometimes lose
> the
[quoted text clipped - 19 lines]
> > View this thread
> http://www.excelforum.com/showthread.php?threadid=560743
Bob Phillips - 18 Jul 2006 11:39 GMT
yeah, that is what you should do

Signature

HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

> ya i have copied that and still nothing.
> Just to make sure I am doing this right.  I have the sheet where these
[quoted text clipped - 31 lines]
> > > View this thread:
> > http://www.excelforum.com/showthread.php?threadid=560743

http://www.excelforum.com/member.php?action=getinfo&userid=32970
> View this thread: http://www.excelforum.com/showthread.php?threadid=560743

Rate this thread:






 
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.