Hi, folks, asking for some advice on how to do this. I have some vba code from another thread here, and was hoping more could be done while it's creating these sheets.
My Data sheet has data in Cols A:H with Col C being the sheet name values. (see pic)
What's needed is to copy matching cell/col values on the data sheet, transpose those to rows on the new sheets being created.
Secondary: The template copied to the new sheet contains 48 columns, and I would like to delete any that won't be used.
(the unused columns on the new sheets won't have data in rows 2 or 3 by that point)
So if values in Col F are in the same row as the Sheet name from Col C, copy those Col F values to the new sheet transposed across the Top Row.
Then do the same with Col D and copy transpose them to Row 2
Then do the same with Col H and copy transpose them to Row 3
The Group column can contain letters and numbers and sometimes both
The Ser # only column can contain / slashes
There could be up to 70 new sheets created.
Example sheet: Col C are sheet names, Copy corresponding Col values F, D, & H and transpose to new sheet, rows 1, 2, & 3
(not the word Row 1, 2, 3, just the values copied)
Thanks to mumps, for this excellent code. I changed it to use Column C for my data.
Right now the code is creating new sheets based on Col C City names, and copying a template to it (the template data starts in row 6, using 48 columns)
Thanks for any assistance!
My Data sheet has data in Cols A:H with Col C being the sheet name values. (see pic)
What's needed is to copy matching cell/col values on the data sheet, transpose those to rows on the new sheets being created.
Secondary: The template copied to the new sheet contains 48 columns, and I would like to delete any that won't be used.
(the unused columns on the new sheets won't have data in rows 2 or 3 by that point)
So if values in Col F are in the same row as the Sheet name from Col C, copy those Col F values to the new sheet transposed across the Top Row.
Then do the same with Col D and copy transpose them to Row 2
Then do the same with Col H and copy transpose them to Row 3
The Group column can contain letters and numbers and sometimes both
The Ser # only column can contain / slashes
There could be up to 70 new sheets created.
Example sheet: Col C are sheet names, Copy corresponding Col values F, D, & H and transpose to new sheet, rows 1, 2, & 3
(not the word Row 1, 2, 3, just the values copied)
Thanks to mumps, for this excellent code. I changed it to use Column C for my data.
Right now the code is creating new sheets based on Col C City names, and copying a template to it (the template data starts in row 6, using 48 columns)
VBA Code:
Sub CreateSheets()
[COLOR=rgb(97, 189, 109)]'//code by mumps from mrexcel.com//[/COLOR]
Application.ScreenUpdating = False
Dim i As Long, v As Variant, wsName As String
Sheets("Data").Visible = True
v = Sheets("Data").Range("C2", Sheets("Data").Range("C" & Rows.Count).End(xlUp)).Value
With CreateObject("Scripting.Dictionary")
For i = 1 To UBound(v, 1)
wsName = Replace(Left(v(i, 1), 31), "/", " ")
If Not .Exists(wsName) Then
.Add wsName, Nothing
If Not Evaluate("isref('" & wsName & "'!C1)") Then
Sheets("Template Sheet").Copy after:=Sheets(Sheets.Count)
ActiveSheet.Name = wsName
[COLOR=rgb(97, 189, 109)] ' Range("B1") = wsName [/COLOR] [COLOR=rgb(147, 101, 184)] '//<-----so here instead of this, make it do the 3 new rows...Starting A1, A2, A3//[/COLOR]
End If
End If
Next i
End With
[COLOR=rgb(97, 189, 109)] 'Sheets("Data").Visible = xlHidden '//not using//[/COLOR]
Application.ScreenUpdating = True
End Sub
Thanks for any assistance!