Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Inputbox Function
Where do I set vbYesNo in a Inputbox? What I am trying to
accomplish is if the user clicks Cancel then it stops the macro. Is it just as simple as putting Cancel as Boolean within the ()? Sub Paste_Macro() On Error GoTo ErrorHandler Dim StrDate As String Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False ActiveCell.Offset(0, -1).Range("A1").Select Application.CutCopyMode = False StrDate = InputBox("What is the date?", "Date Needed") If StrDate = vbCancel Then Exit Sub ActiveCell.FormulaR1C1 = StrDate ActiveCell.Offset(0, 1).Select ActiveCell.Offset(1, 1).Select ActiveWorkbook.Save Exit Sub ErrorHandler: MsgBox Err.Number & " " & Err.Description End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Inputbox Function
Eric,
Try This StrDate = InputBox("What is the date?", "Date Needed") If CloseMode = vbFormControlMenu Then Exit Sub End If Dan E "Eric" wrote in message ... Where do I set vbYesNo in a Inputbox? What I am trying to accomplish is if the user clicks Cancel then it stops the macro. Is it just as simple as putting Cancel as Boolean within the ()? Sub Paste_Macro() On Error GoTo ErrorHandler Dim StrDate As String Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False ActiveCell.Offset(0, -1).Range("A1").Select Application.CutCopyMode = False StrDate = InputBox("What is the date?", "Date Needed") If StrDate = vbCancel Then Exit Sub ActiveCell.FormulaR1C1 = StrDate ActiveCell.Offset(0, 1).Select ActiveCell.Offset(1, 1).Select ActiveWorkbook.Save Exit Sub ErrorHandler: MsgBox Err.Number & " " & Err.Description End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Inputbox Function
Tom,
Test it, it works . . . Paste this code in a macro StrDate = InputBox("What is the date?", "Date Needed") If CloseMode = vbFormControlMenu Then Exit Sub End If Range("A1").Value = "Bill" Click cancel and i'll bet you that A1 isn't Bill. Dan E "Tom Ogilvy" wrote in message ... Where would closemode get its value from. I have only seen it in the queryclose event of a userform where it is set by code internal to the msforms library and passed into the event as an argument. To the best of my knowledge, as shown, closemode would always be an empty variable. Private Sub UserForm_QueryClose(cancel As Integer, closemode As Integer) vbFormControlMenu: The user has chosen the Close command from the Control menu on the UserForm. Regards, Tom Ogilvy "Dan E" wrote in message ... Eric, Try This StrDate = InputBox("What is the date?", "Date Needed") If CloseMode = vbFormControlMenu Then Exit Sub End If Dan E "Eric" wrote in message ... Where do I set vbYesNo in a Inputbox? What I am trying to accomplish is if the user clicks Cancel then it stops the macro. Is it just as simple as putting Cancel as Boolean within the ()? Sub Paste_Macro() On Error GoTo ErrorHandler Dim StrDate As String Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False ActiveCell.Offset(0, -1).Range("A1").Select Application.CutCopyMode = False StrDate = InputBox("What is the date?", "Date Needed") If StrDate = vbCancel Then Exit Sub ActiveCell.FormulaR1C1 = StrDate ActiveCell.Offset(0, 1).Select ActiveCell.Offset(1, 1).Select ActiveWorkbook.Save Exit Sub ErrorHandler: MsgBox Err.Number & " " & Err.Description End Sub |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with Inputbox Function
Nevermind,
HaHa Closemode was just 0 so it appeared to work, my mistake??? "Tom Ogilvy" wrote in message ... Where would closemode get its value from. I have only seen it in the queryclose event of a userform where it is set by code internal to the msforms library and passed into the event as an argument. To the best of my knowledge, as shown, closemode would always be an empty variable. Private Sub UserForm_QueryClose(cancel As Integer, closemode As Integer) vbFormControlMenu: The user has chosen the Close command from the Control menu on the UserForm. Regards, Tom Ogilvy "Dan E" wrote in message ... Eric, Try This StrDate = InputBox("What is the date?", "Date Needed") If CloseMode = vbFormControlMenu Then Exit Sub End If Dan E "Eric" wrote in message ... Where do I set vbYesNo in a Inputbox? What I am trying to accomplish is if the user clicks Cancel then it stops the macro. Is it just as simple as putting Cancel as Boolean within the ()? Sub Paste_Macro() On Error GoTo ErrorHandler Dim StrDate As String Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _ False, Transpose:=False ActiveCell.Offset(0, -1).Range("A1").Select Application.CutCopyMode = False StrDate = InputBox("What is the date?", "Date Needed") If StrDate = vbCancel Then Exit Sub ActiveCell.FormulaR1C1 = StrDate ActiveCell.Offset(0, 1).Select ActiveCell.Offset(1, 1).Select ActiveWorkbook.Save Exit Sub ErrorHandler: MsgBox Err.Number & " " & Err.Description End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
InputBox Help | Excel Discussion (Misc queries) | |||
InputBox with VBA | Excel Discussion (Misc queries) | |||
InputBox | Excel Discussion (Misc queries) | |||
inputbox | Excel Discussion (Misc queries) | |||
Inputbox with VBA | Excel Discussion (Misc queries) |