If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > rename during worksheets().copy

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-05-06, 11:18
izyrider izyrider is offline
Cavalier King Charles
 
Join Date: Dec 2002
Location: Préverenges, Switzerland
Posts: 3,729
rename during worksheets().copy

hi team!

is there a way to rename the new worksheet at the same time as .Copy After

current code:
Code:
    '   /// copy the "VIDE" worksheet into position
    Worksheets("VIDE").Copy After:=Worksheets(strWS)
    '   /// a not-very-smart way to find the new worksheet
    For Each iws In Worksheets
        If Left$(iws.Name, 4) = "VIDE" Then
            If Len(iws.Name) > 4 Then
                strWS = iws.Name
                Exit For
            End If
        End If
    Next
    Worksheets(strWS).Name = strNom
(yes - i was naïve enough to try searching before asking!)

izy
__________________
currently using SS 2008R2

Last edited by izyrider; 09-05-06 at 11:28. Reason: duh! forgot to include the rename line
Reply With Quote
  #2 (permalink)  
Old 09-05-06, 11:44
pootle flump pootle flump is offline
King of Understatement
 
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
Hi Izy

Not to my knowledge or according to the params the copy method accepts (as I'm sure you know).

You could be more efficient getting the sheet:
Code:
Worksheets(Worksheets(strWS).Index +1).Name = strNom
I know you love efficient code:
Code:
LenB(iws.Name) > 8
is ever so slightly more efficient

So - no - short answer is there either isn't an answer or I just don't know it
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
Reply With Quote
  #3 (permalink)  
Old 09-05-06, 12:01
izyrider izyrider is offline
Cavalier King Charles
 
Join Date: Dec 2002
Location: Préverenges, Switzerland
Posts: 3,729
ta Poots!

i'll go with the first of them: it exactly fits the goal.

this activity only occurs on a user double-click a few times a day so efficiency is not a concern this time. goal was to avoid bumping into 'VIDE (2)', 'VIDE (3)' following a previous error of some sort, in turn triggering an error and leaving 'VIDE (2)', 'VIDE (3)', 'VIDE (4)' ad infinitum. my original attempt failed this test in spades.

izy
__________________
currently using SS 2008R2
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On