How to use a common template on my code

niravptl

New Member
Joined
Mar 12, 2018
Messages
10
So I do I set a template to have information look better? I have wrote a code that creates and renames worksheets based on my list. Each worksheet has Net operating income statements. Now I need these sheet look clean and with a common template. So how do I add a template on top of the code I already in VBA.

Sub CopyandPaste()
Dim lastRow As Long
Dim thisRow As Long
Dim nextRow As Long
Dim sheetCount As Long
Dim selectedCells
Dim newSheet As Worksheet
On Error Resume Next
Application.ScreenUpdating = False
lastRow = Sheets("MasterSheet").Cells(Sheets("MasterSheet").Rows.Count, "A").End(xlUp).Row
selectedCells = Application.Selection.Value
For sheetCount = 1 To UBound(selectedCells, 1)
Set newSheet = Sheets.Add(After:=Sheets(Sheets.Count))
newSheet.Name = selectedCells(sheetCount, 1)
nextRow = 2
For thisRow = 2 To lastRow
If Sheets("MasterSheet").Cells(thisRow, "A").Value = selectedCells(sheetCount, 1) Then
Sheets("MasterSheet").Cells(thisRow, "A").EntireRow.Copy Destination:=newSheet.Cells(nextRow, "A")
nextRow = nextRow + 1
End If
Next thisRow
Next sheetCount
Sheets("MasterSheet").Activate
Range("A1").Select
Application.ScreenUpdating = True
End Sub
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Forum statistics

Threads
1,214,909
Messages
6,122,189
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top