Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tried several suggestions, but nothing seems to give me
the result I want. Basically I have a group of fields I want to fill with the result of data gathered from an Inputbox. Sometimes the response will exist, other times users may cancel. I am currently unable to determine when the cancel button has been pressed from the Inputbox dialog. I can determine that the value assigned to the inputbox is blank, but that's an okay condition if the user doesn't want to change the data already in the cell, so I need to be able to determine what's a conscious omission versus the press of a cancel button. Any ideas? Many thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Michelle,
Try something like the following: Dim S As String S = InputBox("Enter something") If S = "" Then If StrPtr(S) = 0 Then MsgBox "User clicked cancel" Else MsgBox "User entered empty string" End If Else MsgBox "User entered: " & S End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Michelle" wrote in message ... Tried several suggestions, but nothing seems to give me the result I want. Basically I have a group of fields I want to fill with the result of data gathered from an Inputbox. Sometimes the response will exist, other times users may cancel. I am currently unable to determine when the cancel button has been pressed from the Inputbox dialog. I can determine that the value assigned to the inputbox is blank, but that's an okay condition if the user doesn't want to change the data already in the cell, so I need to be able to determine what's a conscious omission versus the press of a cancel button. Any ideas? Many thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Brilliant! Worked like a charm. But what DOES StrPtr
really do? I couldn't find it in the help files. Thanks much!! -----Original Message----- Michelle, Try something like the following: Dim S As String S = InputBox("Enter something") If S = "" Then If StrPtr(S) = 0 Then MsgBox "User clicked cancel" Else MsgBox "User entered empty string" End If Else MsgBox "User entered: " & S End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Michelle" wrote in message ... Tried several suggestions, but nothing seems to give me the result I want. Basically I have a group of fields I want to fill with the result of data gathered from an Inputbox. Sometimes the response will exist, other times users may cancel. I am currently unable to determine when the cancel button has been pressed from the Inputbox dialog. I can determine that the value assigned to the inputbox is blank, but that's an okay condition if the user doesn't want to change the data already in the cell, so I need to be able to determine what's a conscious omission versus the press of a cancel button. Any ideas? Many thanks . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Michelle,
StrPtr is not supported by Microsoft, but it is available along with its cousins VarPtr and ObjPtr. Basically, it returns the memory address to which the string variable S points. When the string contents are entirely unallocated, S points to 0. When S contains any string, including a 0 length empty string, StrPtr returns a positive memory address location. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Michelle" wrote in message ... Brilliant! Worked like a charm. But what DOES StrPtr really do? I couldn't find it in the help files. Thanks much!! -----Original Message----- Michelle, Try something like the following: Dim S As String S = InputBox("Enter something") If S = "" Then If StrPtr(S) = 0 Then MsgBox "User clicked cancel" Else MsgBox "User entered empty string" End If Else MsgBox "User entered: " & S End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Michelle" wrote in message ... Tried several suggestions, but nothing seems to give me the result I want. Basically I have a group of fields I want to fill with the result of data gathered from an Inputbox. Sometimes the response will exist, other times users may cancel. I am currently unable to determine when the cancel button has been pressed from the Inputbox dialog. I can determine that the value assigned to the inputbox is blank, but that's an okay condition if the user doesn't want to change the data already in the cell, so I need to be able to determine what's a conscious omission versus the press of a cancel button. Any ideas? Many thanks . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
InputBox with VBA | Excel Discussion (Misc queries) | |||
InputBox | Excel Discussion (Misc queries) | |||
InputBox | Excel Discussion (Misc queries) | |||
how do i put in a parallel line on a cell to show a cancellation | Excel Worksheet Functions | |||
inputbox | Excel Discussion (Misc queries) |