Create worksheet based on lists & populate data from another...
Solved/Closed
harvdog13
Posts
2
Registration date
Thursday February 28, 2013
Status
Member
Last seen
March 1, 2013
-
Feb 28, 2013 at 05:40 PM
sv2bnv - Mar 10, 2014 at 02:27 PM
sv2bnv - Mar 10, 2014 at 02:27 PM
Related:
- Create worksheet based on lists & populate data from another...
- Transfer data from one excel worksheet to another automatically - Guide
- Create skype account with gmail - Guide
- Create instagram account on pc - Guide
- Tmobile data check - Guide
- Create snapchat account - Guide
1 response
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Feb 28, 2013 at 10:23 PM
Feb 28, 2013 at 10:23 PM
Well I must compliment you on doing some thing that to me should be the most obvious thing to do. "Search". Amazes me that people don't even bother to conduct a simple search.
Now on to your issue. Try this
Now on to your issue. Try this
Option Explicit Sub CreateSheetsFromAList() Dim nameSource As String 'sheet name where to read names Dim nameColumn As String 'column where the names are located Dim nameStartRow As Long 'row from where name starts Dim trainingSheet As String 'training material sheet name Dim trainingRange As String 'range to copy from training material sheet Dim nameEndRow As Long 'row where name ends Dim employeeName As String 'employee name Dim newSheet As Worksheet nameSource = "Employee" nameColumn = "A" nameStartRow = 2 trainingSheet = "Training" trainingRange = "A2:B17" 'for example this is range we are going to copy 'find the last cell in use nameEndRow = Sheets(nameSource).Cells(Rows.Count, nameColumn).End(xlUp).Row 'loop till last row Do While (nameStartRow <= nameEndRow) 'get the name employeeName = Sheets(nameSource).Cells(nameStartRow, nameColumn) 'remove any white space employeeName = Trim(employeeName) ' if name is not equal to "" If (employeeName <> vbNullString) Then On Error Resume Next 'do not throw error Err.Clear 'clear any existing error 'if sheet name is not present this will cause error that we are going to leverage Sheets(employeeName).Name = employeeName If (Err.Number > 0) Then 'sheet was not there, so it create error, so we can create this sheet Err.Clear On Error GoTo -1 'disable exception so to reuse in loop 'add new sheet Set newSheet = Sheets.Add(After:=Sheets(Sheets.Count)) 'rename sheet newSheet.Name = employeeName Application.CutCopyMode = False 'clear clipboard 'copy training material Sheets(trainingSheet).Range(trainingRange).Copy 'paste training material Sheets(employeeName).Cells(1, "A").PasteSpecial Application.CutCopyMode = False End If End If nameStartRow = nameStartRow + 1 'increment row Loop End Sub
Mar 1, 2013 at 12:27 PM
May 23, 2013 at 02:45 AM
Sep 20, 2013 at 08:45 AM
Mar 10, 2014 at 02:27 PM
It is very helpful.
Is it possible to auto link the cell from the employee sheet list to the newly created sheet?
For example:
We add to the list the name Tony and it create a new sheet named Tony.
Is it possible to auto link the name to the sheet?
Thank you in advance