Results 1 to 6 of 6

For each loop to create and name worksheets

Threaded View

  1. #3
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: For each loop to create and name worksheets

    Quote Originally Posted by StephenR View Post
    Try this:
    Sub x()
    
    Dim ws As Worksheet, r As Range
    
    With Sheets("Sheet1")
        For Each r In .Range("A2", .Range("A" & Rows.Count).End(xlUp))
            Set ws = Worksheets.Add(after:=Sheets(Sheets.Count))
            ws.Name = r
            ws.Range("A1") = r
        Next r
    End With
            
    End Sub
    This was perfect. Thanks! How could I modify to have it, in addition to naming the sheet and placing the same name in A1, pre-populate A2-A5 of each worksheet with a VLOOKUP referencing the array EmpNameRange? Or would a different code suffice to pull the information x number of columns out during the process you set out previously?

    Revised excel attached.
    Attached Files Attached Files

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