I have a button with a macro assigned. The macro needs to create a new worksheet at the end of the workbook, rename the new sheet to "New County", make the cell size match the rest of the workbook, and then paste in a template from another sheet called "Master".
I recorded a macro that does this, but it has a static reference to the new sheet instead of what ever the new sheet is. So the Macro works one time, but never again. I'm sure this is an easy fix, and perhaps there is a much easier way to do this, but my limited VBA knowledge is hampering me. Any help would be appreciated. Thanks!
I recorded a macro that does this, but it has a static reference to the new sheet instead of what ever the new sheet is. So the Macro works one time, but never again. I'm sure this is an easy fix, and perhaps there is a much easier way to do this, but my limited VBA knowledge is hampering me. Any help would be appreciated. Thanks!
Code:
Sub AddNewCounty()
'
' AddNewCounty Macro
' Adds a new County sheet to the workbook.
'
'
Sheets.Add After:=Sheets(Sheets.Count)
Sheets("Templates").Select
Range("A15").Select
Selection.Copy
Sheets("Sheet3").Select
Sheets("Sheet3").Name = "New County"
Sheets("Master").Select
Range("A1:AN19").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("New County").Select
Cells.Select
Selection.ColumnWidth = 3.57
Range("A1").Select
ActiveSheet.CheckBoxes.Add(293.25, 31.5, 44.25, 15).Select
ActiveSheet.CheckBoxes.Add(360.75, 31.5, 42.75, 15).Select
ActiveSheet.CheckBoxes.Add(428.25, 31.5, 44.25, 15).Select
ActiveSheet.CheckBoxes.Add(495, 30.75, 45, 15).Select
ActiveSheet.CheckBoxes.Add(562.5, 30, 45, 15.75).Select
ActiveSheet.CheckBoxes.Add(630, 31.5, 88.5, 14.25).Select
ActiveSheet.Buttons.Add(787.5, 1.5, 113.25, 78).Select
ActiveSheet.Buttons.Add(787.5, 94.5, 112.5, 78).Select
ActiveSheet.Buttons.Add(787.5, 188.25, 111.75, 78.75).Select
ActiveSheet.DropDowns.Add(585.75, 15.75, 133.5, 15).Select
ActiveSheet.Paste
End Sub