Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
kayabob
 
Posts: n/a
Default Macro Pause during Dialog Box data entry

How can I make a macro pause for user input into a dialog box. As a simple
example, If I have the DATAVALIDATION menu open, how can i make it pause
while I set the validation options, and then continue on with the rest of the
macro after the user hits OK?

Thanks
  #2   Report Post  
Jim Rech
 
Posts: n/a
Default Macro Pause during Dialog Box data entry

Sub a()
MsgBox "Before show"
Application.Dialogs(xlDialogDataValidation).Show
MsgBox "After show"
End Sub

--
Jim
"kayabob" wrote in message
...
| How can I make a macro pause for user input into a dialog box. As a
simple
| example, If I have the DATAVALIDATION menu open, how can i make it pause
| while I set the validation options, and then continue on with the rest of
the
| macro after the user hits OK?
|
| Thanks


  #3   Report Post  
kayabob
 
Posts: n/a
Default Macro Pause during Dialog Box data entry

This works really well, thanks. Do you know where I can find a list of all
the dialog box's exact names?

"Jim Rech" wrote:

Sub a()
MsgBox "Before show"
Application.Dialogs(xlDialogDataValidation).Show
MsgBox "After show"
End Sub

--
Jim
"kayabob" wrote in message
...
| How can I make a macro pause for user input into a dialog box. As a
simple
| example, If I have the DATAVALIDATION menu open, how can i make it pause
| while I set the validation options, and then continue on with the rest of
the
| macro after the user hits OK?
|
| Thanks



  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default Macro Pause during Dialog Box data entry

One way is to search VBA's help for:
"Built-In Dialog Box Argument Lists"



kayabob wrote:

This works really well, thanks. Do you know where I can find a list of all
the dialog box's exact names?

"Jim Rech" wrote:

Sub a()
MsgBox "Before show"
Application.Dialogs(xlDialogDataValidation).Show
MsgBox "After show"
End Sub

--
Jim
"kayabob" wrote in message
...
| How can I make a macro pause for user input into a dialog box. As a
simple
| example, If I have the DATAVALIDATION menu open, how can i make it pause
| while I set the validation options, and then continue on with the rest of
the
| macro after the user hits OK?
|
| Thanks




--

Dave Peterson
  #5   Report Post  
neopolitan
 
Posts: n/a
Default Macro Pause during Dialog Box data entry


Jim, I have wanted to know how to do this for a long time, but I need a
little more explanation on how to employ your code. Where in the code
that I have below would I insert your code? Obviously, I don't want
the column (A) hard-coded in the macro, thus the need for a pause.


Code:
--------------------
Sub ColDataValidation()
'
' ColDataValidation Macro
' Macro recorded 10/19/2005 by neopolitan'

'
With Selection.Validation
.Delete
.Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=countif(A:A,$A1)<=1"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub
--------------------


--
neopolitan


------------------------------------------------------------------------
neopolitan's Profile: http://www.excelforum.com/member.php...nfo&userid=611
View this thread: http://www.excelforum.com/showthread...hreadid=477565



  #6   Report Post  
Jim Rech
 
Posts: n/a
Default Macro Pause during Dialog Box data entry

You really cannot use the code I posted with what you want to do. All my
code does is open the dialog and then lets the user do whatever he wants.
We have no control over what goes in the dialog. In your case you want to
get one input from the user (I think) but other do everything else.

The only way I know of to do what you want is to ask the user for a range
first and then run your code, sticking the range he selected in your code.

This is an example of asking for a range:

Sub GetRg()
Dim Rg As Range
On Error GoTo BadRg
Set Rg = Application.InputBox("Select a range", , , , , , , 8)
Rg.Value = "You selected this range"
Exit Sub
BadRg:
MsgBox "You cancelled"
End Sub

Obviously you'd have to adapt this to your situation by building the code

Formula1:="=countif(A:A,$A1)<=1"

from Rg.Address in some way.


--
Jim
"neopolitan" wrote
in message ...
|
| Jim, I have wanted to know how to do this for a long time, but I need a
| little more explanation on how to employ your code. Where in the code
| that I have below would I insert your code? Obviously, I don't want
| the column (A) hard-coded in the macro, thus the need for a pause.
|
|
| Code:
| --------------------
| Sub ColDataValidation()
| '
| ' ColDataValidation Macro
| ' Macro recorded 10/19/2005 by neopolitan'
|
| '
| With Selection.Validation
| .Delete
| .Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertStop, Operator:= _
| xlBetween, Formula1:="=countif(A:A,$A1)<=1"
| .IgnoreBlank = True
| .InCellDropdown = True
| .InputTitle = ""
| .ErrorTitle = ""
| .InputMessage = ""
| .ErrorMessage = ""
| .ShowInput = True
| .ShowError = True
| End With
| End Sub
| --------------------
|
|
| --
| neopolitan
|
|
| ------------------------------------------------------------------------
| neopolitan's Profile:
http://www.excelforum.com/member.php...nfo&userid=611
| View this thread: http://www.excelforum.com/showthread...hreadid=477565
|


  #7   Report Post  
Dave Peterson
 
Posts: n/a
Default Macro Pause during Dialog Box data entry

And just to add to Jim's response, working with Conditional formatting formulas
can be confusing (well, to me anyway).

It's one time I think it's easier (but not required) to select the range you
want to apply that CF rule to.

You can also use a work-around from John Walkenbach's site:
http://j-walk.com/ss/excel/odd/odd07.htm



Jim Rech wrote:

You really cannot use the code I posted with what you want to do. All my
code does is open the dialog and then lets the user do whatever he wants.
We have no control over what goes in the dialog. In your case you want to
get one input from the user (I think) but other do everything else.

The only way I know of to do what you want is to ask the user for a range
first and then run your code, sticking the range he selected in your code.

This is an example of asking for a range:

Sub GetRg()
Dim Rg As Range
On Error GoTo BadRg
Set Rg = Application.InputBox("Select a range", , , , , , , 8)
Rg.Value = "You selected this range"
Exit Sub
BadRg:
MsgBox "You cancelled"
End Sub

Obviously you'd have to adapt this to your situation by building the code

Formula1:="=countif(A:A,$A1)<=1"

from Rg.Address in some way.

--
Jim
"neopolitan" wrote
in message ...
|
| Jim, I have wanted to know how to do this for a long time, but I need a
| little more explanation on how to employ your code. Where in the code
| that I have below would I insert your code? Obviously, I don't want
| the column (A) hard-coded in the macro, thus the need for a pause.
|
|
| Code:
| --------------------
| Sub ColDataValidation()
| '
| ' ColDataValidation Macro
| ' Macro recorded 10/19/2005 by neopolitan'
|
| '
| With Selection.Validation
| .Delete
| .Add Type:=xlValidateCustom, AlertStyle:=xlValidAlertStop, Operator:= _
| xlBetween, Formula1:="=countif(A:A,$A1)<=1"
| .IgnoreBlank = True
| .InCellDropdown = True
| .InputTitle = ""
| .ErrorTitle = ""
| .InputMessage = ""
| .ErrorMessage = ""
| .ShowInput = True
| .ShowError = True
| End With
| End Sub
| --------------------
|
|
| --
| neopolitan
|
|
| ------------------------------------------------------------------------
| neopolitan's Profile:
http://www.excelforum.com/member.php...nfo&userid=611
| View this thread: http://www.excelforum.com/showthread...hreadid=477565
|


--

Dave Peterson
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
Creating a macro to save only partial data Jparsons Excel Discussion (Misc queries) 0 September 24th 05 10:50 AM
Macro to Synchronize data frm svrl workbooks & columns to 1 workbo jbsand1001 Excel Discussion (Misc queries) 1 April 28th 05 10:42 AM
Macro that will add data from multiple workbooks to the 1st open r jbsand1001 Excel Discussion (Misc queries) 0 April 23rd 05 07:52 PM
Macro does not run when data refreshed Larry Lehman Excel Discussion (Misc queries) 0 January 16th 05 07:31 PM
Pulling data from 1 sheet to another Dave1155 Excel Worksheet Functions 1 January 12th 05 05:55 PM


All times are GMT +1. The time now is 03:17 AM.

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"