Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
InputBox Help Mark[_8_] Excel Discussion (Misc queries) 2 November 24th 08 11:07 PM
InputBox with VBA Mark[_8_] Excel Discussion (Misc queries) 0 November 24th 08 12:39 AM
InputBox peyman Excel Discussion (Misc queries) 4 September 28th 07 04:53 PM
inputbox brownti via OfficeKB.com Excel Discussion (Misc queries) 2 February 9th 07 02:37 PM
Inputbox with VBA Jeff Excel Discussion (Misc queries) 3 January 19th 06 05:18 PM


All times are GMT +1. The time now is 04:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"