Konigsfeldt
New Member
- Joined
- Jun 17, 2020
- Messages
- 13
- Office Version
- 365
- Platform
- Windows
Hi all,
New here - tried to look for a solution but decided to post.
I have the following code, in which I want to either add more to or make a new macro.
This code creates sheets and name them after account numbers, based on a template sheet.
Either in this code, or in another code, I want the values for all rows in column AH:AM in sheet "ReconciledData" that matches the sheet name to be pasted into A21:F21 and downwards. Number of rows can vary from a few to hundreds.
I hope it makes sense, please let me know if I should elaborate further.
Thanks for any feedback.
Sub CreateSheetsFromReconcilidation()
' Example Add Worksheets with Unique Names
Dim MyRange As Range
Dim dic As Object, c As Range
Dim k As Variant, tmp As String
Set dic = CreateObject("scripting.dictionary")
Set MyRange = Sheets("ReconciledData").Range("AE2")
Set MyRange = Range(MyRange, MyRange.End(xlDown))
Sheets("Template").Visible = True
For Each c In MyRange
tmp = Trim(c.Value)
If Len(tmp) > 0 Then dic(tmp) = dic(tmp) + 1
Next c
For Each k In dic.keys
If Not WorksheetExists(k) Then
Sheets("Template").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = k ' renames the new worksheet
ActiveSheet.[B11] = ActiveSheet.Name
End If
Next k
Sheets("Template").Visible = False
Call WorksheetsSortAscending
End Sub
New here - tried to look for a solution but decided to post.
I have the following code, in which I want to either add more to or make a new macro.
This code creates sheets and name them after account numbers, based on a template sheet.
Either in this code, or in another code, I want the values for all rows in column AH:AM in sheet "ReconciledData" that matches the sheet name to be pasted into A21:F21 and downwards. Number of rows can vary from a few to hundreds.
I hope it makes sense, please let me know if I should elaborate further.
Thanks for any feedback.
Sub CreateSheetsFromReconcilidation()
' Example Add Worksheets with Unique Names
Dim MyRange As Range
Dim dic As Object, c As Range
Dim k As Variant, tmp As String
Set dic = CreateObject("scripting.dictionary")
Set MyRange = Sheets("ReconciledData").Range("AE2")
Set MyRange = Range(MyRange, MyRange.End(xlDown))
Sheets("Template").Visible = True
For Each c In MyRange
tmp = Trim(c.Value)
If Len(tmp) > 0 Then dic(tmp) = dic(tmp) + 1
Next c
For Each k In dic.keys
If Not WorksheetExists(k) Then
Sheets("Template").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = k ' renames the new worksheet
ActiveSheet.[B11] = ActiveSheet.Name
End If
Next k
Sheets("Template").Visible = False
Call WorksheetsSortAscending
End Sub