dpaton05
Well-known Member
- Joined
- Aug 14, 2018
- Messages
- 2,375
- Office Version
- 365
- 2016
- Platform
- Windows
I have a button on my spreadsheet that makes a copy of the spreadsheet, here is a screenshot https://www.screencast.com/t/kzrb83Vrar. When I try and make a new document it copies the spreadsheet but the 6 boxes from the Add 10% box get squashed up and I have no idea why. Here is a screenshot of what the file looks like when the new document is made https://www.screencast.com/t/IdCYyLBlVVAT.
The code behind the button that makes the new document is:
The code behind the button that makes the new document is:
Code:
Dim newDoc As String
newDoc = "NPSS work allocation sheet " & Year(Now) + 1 & ".xlsm"
ActiveWorkbook.SaveCopyAs Filename:=newDoc
Workbooks.Open Filename:=newDoc
With Sheets("home")
.Range("B20") = "July " & Year(Now)
.Range("B21") = "August " & Year(Now)
.Range("B22") = "September " & Year(Now)
.Range("B23") = "October " & Year(Now)
.Range("B24") = "November " & Year(Now)
.Range("B25") = "December " & Year(Now)
.Range("E20") = "January " & Year(Now) + 1
.Range("E21") = "February " & Year(Now) + 1
.Range("E22") = "March " & Year(Now) + 1
.Range("E23") = "April " & Year(Now) + 1
.Range("E24") = "May " & Year(Now) + 1
.Range("E25") = "June " & Year(Now) + 1
End With
With Workbooks(newDoc)
.Sheets("July " & Range("E18")).Name = "July " & Year(Now)
With Sheets("July " & Year(Now))
.Range("A4:E2000").Clear
.Range("A1").Value = "501 NPSS " & "July " & Year(Now) + 1
End With
.Sheets("August " & Range("E18")).Name = "August " & Year(Now)
With Sheets("August " & Year(Now))
.Range("A4:E2000").Clear
.Range("A1").Value = "501 NPSS " & "August " & Year(Now)
End With
.Sheets("September " & Range("E18")).Name = "September " & Year(Now)
With Sheets("September " & Year(Now))
.Range("A4:E2000").Clear
.Range("A1").Value = "501 NPSS " & "September " & Year(Now) + 1
End With
.Sheets("October " & Range("E18")).Name = "October " & Year(Now)
With Sheets("October " & Year(Now))
.Range("A4:E2000").Clear
.Range("A1").Value = "501 NPSS " & "October " & Year(Now) + 1
End With
.Sheets("November " & Range("E18")).Name = "November " & Year(Now)
With Sheets("November " & Year(Now))
.Range("A4:E2000").Clear
.Range("A1").Value = "501 NPSS " & "November " & Year(Now) + 1
End With
.Sheets("December " & Range("E18")).Name = "December " & Year(Now)
With Sheets("December " & Year(Now))
.Range("A4:E2000").Clear
.Range("A1").Value = "501 NPSS " & "December " & Year(Now) + 1
End With
.Sheets("January " & Range("E18") + 1).Name = "January " & Year(Now) + 1
With Sheets("January " & Year(Now) + 1)
.Range("A4:E2000").Clear
.Range("A1").Value = "501 NPSS " & "January " & Year(Now) + 2
End With
.Sheets("February " & Range("E18") + 1).Name = "February " & Year(Now) + 1
With Sheets("February " & Year(Now) + 1)
.Range("A4:E2000").Clear
.Range("A1").Value = "501 NPSS " & "February " & Year(Now) + 2
End With
.Sheets("March " & Range("E18") + 1).Name = "March " & Year(Now) + 1
With Sheets("March " & Year(Now) + 1)
.Range("A4:E2000").Clear
.Range("A1").Value = "501 NPSS " & "March " & Year(Now) + 2
End With
.Sheets("April " & Range("E18") + 1).Name = "April " & Year(Now) + 1
With Sheets("April " & Year(Now) + 1)
.Range("A4:E2000").Clear
.Range("A1").Value = "501 NPSS " & "April " & Year(Now) + 2
End With
.Sheets("May " & Range("E18") + 1).Name = "May " & Year(Now) + 1
With Sheets("May " & Year(Now) + 1)
.Range("A4:E2000").Clear
.Range("A1").Value = "501 NPSS " & "May " & Year(Now) + 2
End With
.Sheets("June " & Range("E18") + 1).Name = "June " & Year(Now) + 1
With Sheets("June " & Year(Now) + 1)
.Range("A4:E2000").Clear
.Range("A1").Value = "501 NPSS " & "June " & Year(Now) + 2
End With
.Sheets("All Costings").Range("A4:E2000").Clear
End With
End Sub