Consulting

Results 1 to 3 of 3

Thread: Creating and renaming work sheets to correspond with worksheets of a nother WB

  1. #1
    VBAX Regular
    Joined
    Mar 2009
    Posts
    37
    Location

    Question Creating and renaming work sheets to correspond with worksheets of a nother WB

    I am very new to VBA. I have a problem.

    I have two workbooks..WB1 and WB2. WB1 has 10 Worksheets. I need to create and rename 10 worksheets in WB2 with the same sheet names as WB1.

    Can Some one please help me????????

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Assumes workbooks are open. Rename to suit

    [vba]
    Sub Dups()
    Dim WB1 As Workbook
    Dim WB2 As Workbook
    Dim i As Long
    Set WB1 = book1.xls
    Set WB2 = book2.xls

    For i = WB2.Sheets.Count To 10
    WB2.Sheets.Add
    Next
    For i = 1 To 10
    WB2.Sheets(i).Name = WB1.Sheets(i).Name
    Next
    End Sub

    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular
    Joined
    Mar 2009
    Posts
    37
    Location
    Thanks heaps admin.

Posting Permissions

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