Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default pause vba code until user pastes values in spreadsheet

In my code when a user opens a worksheet I show him a MsgBox asking him if he
is ready to paste the clipboard contents into a certain cell on the
worksheet. The code that executes after the values have been pasted sorts the
values the user has pasted.
The problem is that the sort code executes as soon as the user clicks "yes"
to dismiss the MsgBox, thereby not allowing him an opportunity to perform the
paste operation.
How can I pause the code when the MsgBox is dismissed so that the user can
paste in the values from the clipboard, and then have the code resume
execution after the paste operation has been completed?
All help will be much appreciated.
Or, is there a better way to code for this sequence of events?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default pause vba code until user pastes values in spreadsheet

Hi,

Without seeing you code then it's difficult but in principle you can split
things into 3 modules.

1. Display your message box. The user can click yes or no and nothing
happens until the target cell for the paste changes.

2. This worksheet change code which performs the sort. I used A1 as an
example but this can be anything. it's all a bit marginal in truth because
you can't dictate where the user will paste.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
If Target.Address = "$A$1" Then
'Your sort code
Call yourmacro
End If
End Sub

and then
3 You macro which is called by the change event code.

Mike

"JCIrish" wrote:

In my code when a user opens a worksheet I show him a MsgBox asking him if he
is ready to paste the clipboard contents into a certain cell on the
worksheet. The code that executes after the values have been pasted sorts the
values the user has pasted.
The problem is that the sort code executes as soon as the user clicks "yes"
to dismiss the MsgBox, thereby not allowing him an opportunity to perform the
paste operation.
How can I pause the code when the MsgBox is dismissed so that the user can
paste in the values from the clipboard, and then have the code resume
execution after the paste operation has been completed?
All help will be much appreciated.
Or, is there a better way to code for this sequence of events?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default pause vba code until user pastes values in spreadsheet

Thanks, Mike. Sorry that I haven't responded sooner. I've been away from my
desk. (and for some reason I didn't get an e-mail about your post). I should
have enclosed a snippet of the code. But, I think you've given me a solution
to the problem. I'll try that route and get back to you if I need to. Again,
thanks for your help.

jcirish

"Mike H" wrote:

Hi,

Without seeing you code then it's difficult but in principle you can split
things into 3 modules.

1. Display your message box. The user can click yes or no and nothing
happens until the target cell for the paste changes.

2. This worksheet change code which performs the sort. I used A1 as an
example but this can be anything. it's all a bit marginal in truth because
you can't dictate where the user will paste.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
If Target.Address = "$A$1" Then
'Your sort code
Call yourmacro
End If
End Sub

and then
3 You macro which is called by the change event code.

Mike

"JCIrish" wrote:

In my code when a user opens a worksheet I show him a MsgBox asking him if he
is ready to paste the clipboard contents into a certain cell on the
worksheet. The code that executes after the values have been pasted sorts the
values the user has pasted.
The problem is that the sort code executes as soon as the user clicks "yes"
to dismiss the MsgBox, thereby not allowing him an opportunity to perform the
paste operation.
How can I pause the code when the MsgBox is dismissed so that the user can
paste in the values from the clipboard, and then have the code resume
execution after the paste operation has been completed?
All help will be much appreciated.
Or, is there a better way to code for this sequence of events?

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
Spreadsheet pastes as picture Worker Bee[_2_] Excel Discussion (Misc queries) 1 February 6th 09 01:28 AM
Code that searches a column, then copies and pastes any matches intoa new Spreadsheet Mike C[_5_] Excel Programming 5 February 8th 08 04:02 AM
Pause a macro for user input RBLampert Excel Programming 15 November 23rd 07 05:30 AM
Pause VB Code to Allow User Input on Worksheet Jana[_3_] Excel Programming 4 August 4th 07 12:04 AM
change a macro so that it copies and pastes data as values rather than references Meg[_2_] Excel Programming 3 December 17th 03 09:35 PM


All times are GMT +1. The time now is 10:23 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"