Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50259

Detecting a user input box cancel

$
0
0
Hi,

I cannot get this code to work if the user cancels hits the cross or enters nothing.

Code:

Sub Reset()
 Dim newyr As Date
 Dim Tmpl As Worksheet
    Set Tmpl = ThisWorkbook.Sheets("Template")
   
    newyr = (InputBox("Enter first date of Week 1 of new calender year", "Enter Date (DD/MM/YYYY)"))
    If Len(newyr) = 0 Then GoTo Cancel2
   
    Sheet5.Range("A5").Value = newyr
    Sheet5.Range("A5").NumberFormat = "dd/mm/yyyy;@"

Cancel2 then exits the sub

Can anyone offer any assistance?

John

Viewing all articles
Browse latest Browse all 50259

Trending Articles