Hi there,
I have been coding for a while so know the basics fairly well. I have, however come across an issue (Code is posted below).
I am trying to write a macro where it will create a new sheet, name it and do some basic stuff but then i want it to loop through any other worksheets available in the workbook and copy the used range there and paste it in the newly created sheet in order.
Theoretically, i would ask it to offset but i have been unsuccessful. I would appreciate any help with the code and perhaps guidance as to where I've gone wrong.
Many thanks
Code:
Sub FeeStatement()
On Error Resume Next
Sheets(1).Select
Worksheets.Add
Sheets(1).Name = "Consolidated Fee Statement"
Worksheets("Consolidated Fee Statement").Range("A1").Value = "Insert Name"
Worksheets("Consolidated Fee Statement").Range("A1").Font.Bold = True
Worksheets("Consolidated Fee Statement").Range("A2").Value = "Fee Statement"
Worksheets("Consolidated Fee Statement").Range("A3").Value = Date
Worksheets("Consolidated Fee Statement").Range("A3").Select
Selection.Copy
Worksheets("Consolidated Fee Statement").Range("A3").PasteSpecial xlPasteValues
Dim i As Worksheet
For Each i In ActiveWorkbook.Sheets
If ws.Name <> "Consolidated Fee Statement" Then
ws.Activate
i.UsedRange("A1:M5").Select
Selection.Copy
Worksheets("Consolidated Fee Statement").Range("A10" & Count).PasteSpecial xlPasteValues
Else: MsgBox "Error"
End If
Next i
End Sub
I have been coding for a while so know the basics fairly well. I have, however come across an issue (Code is posted below).
I am trying to write a macro where it will create a new sheet, name it and do some basic stuff but then i want it to loop through any other worksheets available in the workbook and copy the used range there and paste it in the newly created sheet in order.
Theoretically, i would ask it to offset but i have been unsuccessful. I would appreciate any help with the code and perhaps guidance as to where I've gone wrong.
Many thanks
Code:
Sub FeeStatement()
On Error Resume Next
Sheets(1).Select
Worksheets.Add
Sheets(1).Name = "Consolidated Fee Statement"
Worksheets("Consolidated Fee Statement").Range("A1").Value = "Insert Name"
Worksheets("Consolidated Fee Statement").Range("A1").Font.Bold = True
Worksheets("Consolidated Fee Statement").Range("A2").Value = "Fee Statement"
Worksheets("Consolidated Fee Statement").Range("A3").Value = Date
Worksheets("Consolidated Fee Statement").Range("A3").Select
Selection.Copy
Worksheets("Consolidated Fee Statement").Range("A3").PasteSpecial xlPasteValues
Dim i As Worksheet
For Each i In ActiveWorkbook.Sheets
If ws.Name <> "Consolidated Fee Statement" Then
ws.Activate
i.UsedRange("A1:M5").Select
Selection.Copy
Worksheets("Consolidated Fee Statement").Range("A10" & Count).PasteSpecial xlPasteValues
Else: MsgBox "Error"
End If
Next i
End Sub