miamidawgs
New Member
- Joined
- Apr 30, 2019
- Messages
- 4
Hi, I am new to VBA and trying to create a form for a gas station. The form is made so a user can enter sales information and it will calculate month to date totals as pages are added through a new day button at the top. The button should create a new sheet that is named as the next day. The code I have works when u press it once but if it is pressed a second time it doesn't change the date. Is there a better way I can do this?
Code:
Private Sub CommandButton1_Click()
Dim strTemplate As String: strTemplate = "C:\Users\Saif\Documents\Custom Office Templates\GasStationForm.xltm"
Dim counter As Integer
counter = counter + 1
Sheets.Add After:=Sheets(Sheets.Count), Type:=strTemplate
ActiveSheet.Name = Format(Date + counter, "YYYY-MM-DD")
End Sub