View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
[email protected][_2_] Jason.Alden.Benoit@gmail.com[_2_] is offline
external usenet poster
 
Posts: 8
Default Generate sheet names from list, assign data to summary sheet.

Thanks, that did the trick! Below is my current coding, adjusted for
me:

Sub TabsFromList()
'David McRitchie based on previous code in sheets.htm
Application.ScreenUpdating = False
Dim cell As Range
Dim newName As String, xx As String
Err.Description = ""
On Error Resume Next
'--cells with numbers, including dates, will be ignored,
For Each cell In Intersect(Selection, _
Selection.SpecialCells(xlConstants, xlTextValues))
'Sheets.Add after:=Sheets(Sheets.Count)

Worksheets("Template").Copy after:=Worksheets(Worksheets.Count)

If Err.Description < "" Then Exit Sub
Err.Description = ""
newName = cell.Text
ActiveSheet.Name = newName
If Err.Description < "" Then
'--failed to rename, probably sheetname already exists...
xx = MsgBox("Failed to rename inserted worksheet " & _
vbLf & _
ActiveSheet.Name & " to " & newName & vbLf & _
Err.Number & " " & Err.Description, vbOKCancel, _
"Failed to Rename Worksheet, it will be deleted:")
'--eliminate already created sheet that failed to be
renamed...
Application.DisplayAlerts = False
ActiveSheet.Delete
Application.DisplayAlerts = True
'--check for immediate cancellation...
If xx = vbCancel Then Exit Sub
Err.Description = ""
End If
Next cell
Application.ScreenUpdating = True
End Sub
Sub WeeklyTallyNames()
Sheets("Weekly Tally").Activate
k = 4
For Each w In Sheets
AgentName = w.Name
If nm < "Template" Then
Cells(3, k).Value = AgentName
k = k + 1
End If
Next
End Sub
Sub GenerateAgents()
Call TabsFromList
Call WeeklyTallyNames
End Sub


Can I exclude certain sheets from having their names copied into the
Weekly Tally sheet?

The next thing I am working on and haven't figured out how to go
about it yet is I need to take the range V6:X66 from each named sheet
and copy that data below the corresponding name that was entered into
the cells from the "jason" macro. So the first set of data will go to
D6:F66, the next set G66:I66, etc looping until the sheet names are
all covered. If I could used a named range so that I can more easily
port the coding to another sheet that would be best. Currently B4 is
the cell that I have slated to contain the sheet names in, which is
already setup to do automatically. Any ideas on how to go about that?

Thanks again!


On Jun 17, 3:43 pm, Gary''s Student
wrote:
Sub Main
Call TabsFromList
Call jason
End Sub

will call our two programs sequentially. As currently written, jason will
put headers in A1, E1, I1, M1, etc.

This version will start in D4 rather than A1:

Sub jason()
Sheets("summary").Activate
k = 4
For Each w In Sheets
nm = w.Name
If nm < "summary" Then
Cells(4, k).Value = nm
k = k + 4
End If
Next
End Sub

Only two lines changed. The headers will now go in:
D4, H4, L4, .....

--
Gary''s Student - gsnu200730