Chris
Mon Jun 09 06:45:55 CDT 2008
Bob,
When I put the code in Sheet 1 this code makes the list worksheet change
name, but not the worksheet that should. When I put the code in the
ThisWorkbook-section nothing happens. I am probably doing something wrong,
but what?
Chris
"Bob Phillips" <bob.NGs@somewhere.com> schreef in bericht
news:uHZobjgyIHA.3968@TK2MSFTNGP04.phx.gbl...
> Try this version
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> Dim i As Long
> Dim LastRow As Long
> Dim NextSheet As Long
> Dim sh As Worksheet
>
> If Not Intersect(Target, Me.Range("A:A")) Is Nothing Then
>
> LastRow = Me.Cells(Me.Rows.Count, "A").End(xlUp).Row
> NextSheet = 1
> For i = 2 To LastRow
>
> If Me.Cells(i, "A").Value <> "" Then
>
> Set sh = Nothing
> On Error Resume Next
> Set sh = Worksheets(Me.Cells(i, "A").Value)
> On Error GoTo 0
> If sh Is Nothing Then
>
> Sheets(NextSheet).Name = Me.Cells(i, "A").Value
> NextSheet = NextSheet + 1
> End If
> End If
> Next i
> End If
> End Sub
>
>
> --
> ---
> HTH
>
> Bob
>
>
> (there's no email, no snail mail, but somewhere should be gmail in my
> addy)
>
>
>
> "Chris" <cclaes@telenet.be> wrote in message
> news:eyX2k.95791$Ex2.95057@newsfe12.ams2...
>> Hi Shane,
>>
>> I tried the code you proposed, but I get an error on the 'Sheets(I +
>> 1).Name = cell'-part.
>> Do I have to alter anything in the code?
>>
>> Chris
>>
>>
>> "Shane Devenshire" <shanedevenshire@sbcglobal.net> schreef in bericht
>> news:eRm0XsZyIHA.4376@TK2MSFTNGP06.phx.gbl...
>>> Hi Chris,
>>>
>>> Once your added the sheets with names, then the following macro will
>>> rename all the sheets anytime you make a change to the names you list in
>>> the range A2:A20. This code goes in the code module for the sheet with
>>> the names list. For example Sheet1.
>>>
>>> Private Sub Worksheet_Change(ByVal Target As Range)
>>> Dim cell As Range
>>> Dim I As Integer
>>> Dim IntSec As Excel.Range
>>>
>>> Set IntSec = Application.Intersect(Target, [A2:A20])
>>> If Not IntSec Is Nothing Then
>>> I = 1
>>> For Each cell In Range("A2:A20")
>>> If cell <> "" Then
>>> Sheets(I + 1).Name = cell
>>> I = I + 1
>>> End If
>>> Next cell
>>> End If
>>> End Sub
>>>
>>> Cheers,
>>> Shane Devenshire
>>> Microsoft Excel MVP
>>> Join
http://setiathome.berkeley.edu/ and download a free screensaver to
>>> help search for life beyond earth.
>>>
>>> "Chris" <cclaes@telenet.be> wrote in message
>>> news:cZT2k.5250$pu3.161@newsfe05.ams2...
>>>> Hello
>>>>
>>>> On my first worksheet there is a list of names. I would like these
>>>> names to
>>>> come in the tab of the following worksheets because for every person in
>>>> the
>>>> list there is a seperate worksheet with data and calculations.
>>>>
>>>> i.e. worksheet with list of names = LIST. 2nd worksheet=John, 3rd
>>>> worksheet=Mary, according to the list on the LIST-worksheet.
>>>>
>>>> Is this possible?
>>>>
>>>> Thank you for any kind of help.
>>>> Chris
>>>>
>>>>
>>>>
>>>>
>>>>
>>
>>
>
>