Results 1 to 10 of 10

Using VBA to copy and name a worksheet

Threaded View

foxtrotdelta Using VBA to copy and name a... 10-30-2008, 12:10 PM
StephenR Perhaps like this? Sub x()... 10-30-2008, 12:24 PM
foxtrotdelta Hmmm - well, it seems to like... 10-30-2008, 12:33 PM
shg Try changing ... 10-30-2008, 01:07 PM
foxtrotdelta And now I have a new error! ... 10-31-2008, 05:18 AM
  1. #1
    Registered User
    Join Date
    10-27-2008
    Location
    Southampton, UK
    Posts
    12

    Using VBA to copy and name a worksheet

    I'm trying to use VBA to automatically copy a worksheet (within the same workbook) and then give that worksheet a name dictated by the contents of a cell. I have pulled together some code by searching forums etc but it just ain't working...

    Code is:

    
    Dim WsName As String
        
    Sheets("Pt_Type_Query").Range("U3").Select
    
    Do
    ActiveCell.Offset(l, 0).Select
    
    With Target
        Set WsName = ActiveCell.Value
    End With
        
        Sheets("1").Select
        Sheets("1").Copy After:=Sheets("1")
            
        ActiveSheet.Name = WsName.Value
    
    l = 1
    
    Loop Until ActiveCell.Value = ""
    The line that appears to be causing problems is highlighted in red...

    Thanks in advance to anyone who can solve this!
    Last edited by foxtrotdelta; 10-30-2008 at 12:19 PM. Reason: Correcting some of the code which I realised I'd got wrong.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1