I am a novice when it comes to making macros so I am in desperate need of help. I have two worksheets, one with data that will be updated with new data everyday and the other, a template that the data needs to fill in by each row accordingly. However the template needs to be a copy of the unique name from column A and renamed by that name. If the template worksheet already exist it will take the information from that matching name and copy certain information to the template. If there is no worksheet(template) existent then it will create a new worksheet according to that unique value from column "A".
The data in worksheet(data) will first need to be filtered by two types, "Redemption" and "Full Liquidation" from column "I" before it can start transferring data.
From worksheet(data) to worksheet(template),
column "A" will be the new worksheet(template) name,
column "E" will be put in Worksheet(template) column "A" starting with row 4,
column "F" will be in column "B",
column "B" will be in column "C",
column "O" will be in column "D",
column "L" will be in column "T".
So far I have this as a Macro, but it does not copy the template and it takes the whole row instead of the specific columns that I need.
Sub PagesByDescription()
Dim rRange As Range, rCell As Range
Dim wSheet As Worksheet
Dim wSheetStart As Worksheet
Dim strText As String
Set wSheetStart = ActiveSheet
wSheetStart.AutoFilterMode = False
'Set a range variable to the correct item column
Set rRange = Range("A1", Range("A65536").End(xlUp))
'Add a sheet called "UniqueList"
Worksheets.Add().Name = "UniqueList"
'Filter the Set range so only a unique list is created
With Worksheets("UniqueList")
rRange.AdvancedFilter xlFilterCopy, , _
Worksheets("UniqueList").Range("A1"), True
'Set a range variable to the unique list, less the heading.
Set rRange = .Range("A2", .Range("A65536").End(xlUp))
End With
On Error Resume Next
With wSheetStart
For Each rCell In rRange
strText = rCell
.Range("A1").AutoFilter 1, strText
Worksheets(strText).Delete
'Add a sheet named as content of rCell
Worksheets.Add("CLASS GROUPING ID").Name = strText
'Copy the visible filtered range _
(default of Copy Method) and leave hidden rows
.UsedRange.Copy Destination:=ActiveSheet.Range("A1")
ActiveSheet.Cells.Columns.AutoFit
Next rCell
End With
With wSheetStart
.AutoFilterMode = False
.Activate
End With
On Error GoTo 0
Application.DisplayAlerts = True
End Sub
Please help I'm in desperate need of some guidance
The data in worksheet(data) will first need to be filtered by two types, "Redemption" and "Full Liquidation" from column "I" before it can start transferring data.
From worksheet(data) to worksheet(template),
column "A" will be the new worksheet(template) name,
column "E" will be put in Worksheet(template) column "A" starting with row 4,
column "F" will be in column "B",
column "B" will be in column "C",
column "O" will be in column "D",
column "L" will be in column "T".
So far I have this as a Macro, but it does not copy the template and it takes the whole row instead of the specific columns that I need.
Sub PagesByDescription()
Dim rRange As Range, rCell As Range
Dim wSheet As Worksheet
Dim wSheetStart As Worksheet
Dim strText As String
Set wSheetStart = ActiveSheet
wSheetStart.AutoFilterMode = False
'Set a range variable to the correct item column
Set rRange = Range("A1", Range("A65536").End(xlUp))
'Add a sheet called "UniqueList"
Worksheets.Add().Name = "UniqueList"
'Filter the Set range so only a unique list is created
With Worksheets("UniqueList")
rRange.AdvancedFilter xlFilterCopy, , _
Worksheets("UniqueList").Range("A1"), True
'Set a range variable to the unique list, less the heading.
Set rRange = .Range("A2", .Range("A65536").End(xlUp))
End With
On Error Resume Next
With wSheetStart
For Each rCell In rRange
strText = rCell
.Range("A1").AutoFilter 1, strText
Worksheets(strText).Delete
'Add a sheet named as content of rCell
Worksheets.Add("CLASS GROUPING ID").Name = strText
'Copy the visible filtered range _
(default of Copy Method) and leave hidden rows
.UsedRange.Copy Destination:=ActiveSheet.Range("A1")
ActiveSheet.Cells.Columns.AutoFit
Next rCell
End With
With wSheetStart
.AutoFilterMode = False
.Activate
End With
On Error GoTo 0
Application.DisplayAlerts = True
End Sub
Please help I'm in desperate need of some guidance