Macro To Pause Code, Another To Resume
Jul 27, 2007
I have a workbook with several hundred row the VBA code loops through. It takes about an hour to run all the calculations. Whenever I need to pause the script I hit ESC, which works well for me, but for other users it would be nice to have a command button that halts code. Even better would be another button to resume code.
View 9 Replies
ADVERTISEMENT
Nov 11, 2012
Is there a way a macro can be paused then resume running the macro by a keystroke, not a time delay.
View 3 Replies
View Related
Jan 15, 2014
I have a macro where I manually select a cell then the macro kicks in to copy and paste the contents into the Find function. From there it goes to another work sheet, clicks on a cell in column one and searches for matching cell contents. Then If false it manually goes back to the original worksheet/cell and then I input a N in the left adjacent cell. If true I enter a Y. Right now I can only run this for the specific cell the macro was recorded for. I would like to expand this.
What I would like to do create a loop in the macro that waits for my cell choice input then continues with the with the Find function. If false the macro should just loop back to the original worksheet/cell and wait for input, ie the next cell selected. However, if true a worksheet/cell is selected, a Y is input and it loops back to the original cell and waits for input.
View 9 Replies
View Related
Mar 14, 2007
how to interrupt VBA code, allow user modifications to a chart, and then continue the code where it left off with a click of a button. I currently have the code in place where a UserForm pops up at a specific point and tells the user to make adjustments and press OK when done. It works fine but the UserForm displays and the macro resumes when OK is clicked, but I can't figure out how to activate the chart or the spreadsheet to allow editing while that UserForm is on the screen. If only I can get excel to allow me to sleect the spreadsheet and make changes while the UserForm is on the screen, I would be set. Can anyone please help me with any options to allow editing while the UserForm is on the screen so I can edit and then click the OK when done?
I posted something similar to this over two years ago. The way I got around it at the time was to break the code into two separate subs. This time around, the code is making 17 graphs and I want to ask for editing for each one before continuing. That would be a lot of individual sections of code.
View 9 Replies
View Related
Oct 23, 2008
Before doing some modifications in a data sheet, I first check with the below code whether a certain list is complete or not using the VLOOKUP function. If I encounter a missing value in the list, a userform appears asking to fill out 3 data fields, which are then added to the original list to complete it. All of this works fine if only one line is missing; if there are two (or more) lines missing, all goes well untill the VLOOKUP function errors out on the second line missing.
I can't find out why everythign goes welll with the first missing line, but not with the second missing line.
Sub proCheckVesselCodes()
Sheets("Sheet4").Select
Range("K1").Value = "Check"
Set varRange1 = Range("A1")
fctCountNrRows
varRow1 = varRow
varRow2 = 2
jump:
On Error Goto addvessel...............
View 3 Replies
View Related
Oct 27, 2008
I have a situation where I have an msg box pop up that asks the user to identify whether or not the file they have chosen meets the standards needed to continue running the macro. Specifically, I need them to answer "Yes" if the file has a list of data in the first column, if there are no blanks in that list and if the first row of data begins on Row 4. If they answer yes, the macro continues ahead and does what it needs to. If the person selects "no," another input box pops up that asks the user to make the edits. This msg box asks the user to click "ok" when they have made those edits. I want the macro to pause after the person has selected "no" from the first msg box, so that the person can make those corrections. Then, I want the macro to resume when the user selects "OK" on the second msg box. How might I do this? I have included the piece of my code below.
strresponse2 = MsgBox("Please confirm that the file you have selected meets the following standards:" & vbNewLine & "1. The information in the first column of this file is all of the job titles or job codes associated with this profile." & vbNewLine & "2. From the first job code or title to the last, there are no blank rows in this first column of data." & vbNewLine & "3. The first job title or code appears on Row 4, Column 1." & vbNewLine & "If the file you selected meets these standards, select Yes. If the file you selected does not meet these requirements, select No.", vbYesNo, "Yes/No")
If strresponse = 6 Then
Call getjobtitle
End If
If strresponse = 7 Then
'pause macro
strresponse2 = MsgBox("Please make the necessary edits to this file. When you are done, select OK to continue generating your job profile.", vbOKOnly, "OK")
If strresponse = 0 Then
'resume macro
Call getjobtitle
End If
End If
View 5 Replies
View Related
Oct 10, 2007
I need to PAUSE my VBA code (about halfway through) in order to verify some calculations before I can allow the macro to finish running. If the numbers are correct, then I'd like the macro to finish running accordingly. However, if the numbers are incorrect, I need to be able to search my Excel file for the error (the error would be due to a format issue with the data that I pulled in), fix the error, and then let the macro finish running from the point it was paused.
Right now, I've got a Message Box that pops up asking me if the numbers are right and I have to answer YES or NO. I always answer NO so that the macro crashes -- this allows me to check the excel file without having to stop the macro. Once I've fixed the data problem, then I go back into my code and let it run to its conclusion.
View 6 Replies
View Related
Dec 6, 2007
I have searched and not found a solution. I have a project that requires the item to be printed on two different types of paper from a printer. The only way i have found to change trays is the sendkeys option. But it looks like sendkeys cannot send, then pause, then send. ex:
' first select the correct printer
Application.ActivePrinter = "\hagenCopy Room Savin 4045 PCL6 on Ne05:"
' next set change printing options, presses ok to print
Application.SendKeys "%fp%r+{TAB}{RIGHT}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{UP}{UP}{UP}{UP}{UP}{UP}{DOWN}{DOWN}~%c3~", True
' next set change printing options to other color tray, presses ok to print
Application.SendKeys "%fp%r+{TAB}{RIGHT}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{TAB}{UP}{UP}{UP}{UP}{UP}{UP}{DOWN}{DOWN}{DOWN}~%c1~", True
How would one insert a working pause inbetween the two sendkeys (a wait just waits before the beginning of the first sendkey. and then the 2 try to execute at the same time calcelling both)
View 6 Replies
View Related
Dec 18, 2007
I am trying to pause a macro on a protected sheet, select 2 adjacent cells (initially protected), utilize an existing drop down box to select a name from the list, copy the name from the list into the range of cells, then re-start the macro.
I had no problem when there was just one name (see John Smith below). I tried to use the InputBox command but needed to actually type in the name.
ActiveSheet.Unprotect
Range("C27:D27").Select
'ActiveCell.FormulaR1C1 = "John Smith"
' Application.CutCopyMode = False
' ActiveSheet.Paste
'Range("c27:d27") = InputBox("Enter value")
View 4 Replies
View Related
Oct 23, 2012
is there a code i can have where i can a pause a macro and then run it after 10 mins from that point?
View 5 Replies
View Related
Jun 24, 2006
I am running a macro that populates the same chart with variable data. I have approximately 40 sets of data and wish to pause or stop the macro to view one of the sets of data more closely. The pause option would be better but Stop option is acceptable
View 2 Replies
View Related
Jul 3, 2014
I have macros that often pause for the user to take some action -- for instance, to confirm that the correct cells are selected, or to delete something. Usually I use the "Stop" command, which opens the VBA editor; when I finish doing the manual action, I just resume the macro.
When writing macros for actual users, I'd like to do the same thing without their having to deal with the VBA window. Is there a way to pause and resume action and remain in the Excel window?
View 3 Replies
View Related
Mar 19, 2014
I've written a macro for work that will work with our billing process. After part of it has run, I'd like to pause it for the user to check a column for errors and possibly update a table to get rid of those errors, then after those errors are fixed, have the ability to continue with the rest of the code. I tried to make a message box to remind the user to look for the errors, but it wouldn't allow me to click anywhere except for on the buttons.
View 4 Replies
View Related
Mar 21, 2013
I would like to add a pause to the following macro so that it inserts the word CANCEL 1 second after triggering. I know I need to use the Application.Ontime function but cannot work out how to integrate it.
Code:
Sub Cancel() Application.ScreenUpdating = False
Sheets("Sheet1").Range("T5") = "CANCEL"
Application.ScreenUpdating = True
End Sub
View 3 Replies
View Related
Nov 17, 2006
I'm recording a Macro but I want to test certain section before I complete it, so can I pause the recording and then restart the recording again?
View 9 Replies
View Related
Nov 21, 2006
I am running a Showcase query from inside excel. I want the query to update, drop the data in excel save it and then close. The problem is that the save command is executing before the data is dropped. The Wait command pauses all processes so it won't work. Is there a way to have a minute of filler until the data is dropped so it will save?
View 5 Replies
View Related
Aug 15, 2014
I am wanting to pause a macro to allow a user to select a cell and when the user hits enter the macro starts running again. My intention is that a user would select cell B5 or B8 or B55 and then hit enter and the cell would move 6 cells right and enter a value from the macro. The following is what I have tried and even though it allows to select a cell, it doesn't make that cell the active cell.
[Code].....
View 3 Replies
View Related
Feb 18, 2008
I would like to Pause a macro to allow the user to select a range on the spreadsheet and then click OK to continue with Macro.
I tried to use Msbbox, but I can't figure out how to allow user to access the spreadsheet to highlight the desired range.
View 9 Replies
View Related
Jan 20, 2010
Why doesn't this code exit on the first "Cancel" selection from the first inputbox?
When I select Cancel from the first inputbox it goes to the next inputbox and I have to select Cancel again, then it exits the sub.
View 4 Replies
View Related
Apr 10, 2008
Cells.Find(What:="flags", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
'if there is an error, ignore it and continue
On Error Resume Next
Selection.EntireColumn.SpecialCells(xlCellTypeConstants, 1).EntireRow.Delete Shift:=xlUp
'reset normal error handling
On Error GoTo 0
I am finding the cell marked "flags", then in that column look for the special cell and delete the rows where they are found. It works when it actually finds those cells, but it reports an error when no cells were found.
View 9 Replies
View Related
Jun 2, 2006
Is there a way to resume running a code should there be an incompatible file that causes an error? Currently I'm reading a bunch of excel sheets, but there might be some sheets that aren't formated as such and cause an error 400.
View 5 Replies
View Related
May 15, 2008
Using the code I got from the Forum Drop Down I added the subs to put a custom command button in the right menu. The first thing it does is delete any existence of the menu item so that you don't get a new one every time you right click your menu. I has just a clear as day "On Error Resume Next". But when it encounters the delete command the error dialog pops up and says "Run time error 5. Invalid procedure call or argument."
View 4 Replies
View Related
Aug 3, 2009
I'm trying to have a macro move down one cell and resume from the start if it finds nothing.
View 14 Replies
View Related
Aug 4, 2007
I have 2 basic parts to a Macro which need to be separated by a pause of 1 second, before proceeding to the next part of the macro. Then pause for 1 second, and loop.
Application.Wait is no good to me as the spreadsheet must remain live, editable, and receiving updates from an external program linked via DDE. Below is the ...
View 6 Replies
View Related
Apr 24, 2008
I've got some code (at bottom) which works very well for small groups of data but when it gets large it hangs excel. Had heard that I can make code which will get it to pick up on the row after where it left off rather than having it run the entire loop again. Specifically speaking of the raw data sheet. It is sorted by date and by code so that if it works on the first code for the date it won't have to return to that row again for data. Uncertain how to implement that approach. (sample data layout below)
Option Explicit
Sub DoubleDirectionLoop()
Dim Wb As Excel.Workbook
Dim Ws1 As Excel.Worksheet, Ws2 As Excel.Worksheet
Dim iCol As Integer
Dim iRow As Integer, iRow2 As Integer
Dim Loop1 As Integer, Loop2 As Integer
Dim Loop3 As Integer, PeakSum As Long
View 9 Replies
View Related
Sep 1, 2006
I use the following code to assign a macro to right arrow key.
Application.OnKey "{RIGHT}", "myMACRO"
My questin is how to let the right arrow key resume its normal function, that is move from left to right (A2 to A1) if I do not want the macro any more and without quit and restart EXCEL? The following code disabes the right arrow key's normal function. Application.OnKey "{RIGHT}", ""
View 2 Replies
View Related
Feb 1, 2007
The following code shows the bare bones which illustrate my problem. The routine runs whenever the user enters a string which begins "Frm1=" and contains exactly three commas.
My problem is with the MsgBox which appears if the ErrorHandler is reached. With the following code the MsgBox requires two clicks on OK to dismiss it. If I change Resume to GoTo it requires only one. Is this normal? Is there any way of dismising the MsgBox with one click? ...
View 9 Replies
View Related
Aug 10, 2012
I have some code below. I have error handling in place for when it tries to open a specific file. If it isn't there then user has option to continue and ignore this file, or browse and select a new one.
The problem is, when the user wants to ignore the file, the "Resume Next" continues to run the VBA assuming the file was ok i.e. the code after the line to open the file. What I would like is for it to skip the succeeding code and go to look for the next file.
Below is the VBA:
Code:
For i = 0 To 2 Step 1
'add in error handling for if the file is missing
On Error GoTo MissingFile
Workbooks.Open Filename:="\hbeu.adroot.hsbcdfsrootgb002hfcfinance01fnce" & qfolder & "Data" & qfile(i), UpdateLinks:=False, ReadOnly:=True
[Code] .........
Missing File:
qMissingPrompt = "There was an error opening data file. Click OK to browse or Cancel to ignore and move to next file"
qAns = MsgBox(qMissingPrompt, vbOKCancel)
'click cancel - ignore error and move onto the next file
If qAns = vbCancel Then
[Code] .......
So, where it says Resume Next, currently it will start running the following (after On Error Goto 0)
Code:
Set datawb = ActiveWorkbook
range("A2").Select
Do Until ActiveCell.Value = ""
etc.
What I would like it to do is go back to is to go to the next i
Code:
For i = 0 To 2 Step 1
Or even to go to the 'Next' statement at the end so that it moves onto the Next i and tries to open the next file.
View 2 Replies
View Related
Mar 16, 2009
Hi everyone I am having a little trouble with a sheet i'm currently working on. Having exhausted what i believe to be every avenue trying to do this without VBA, i've finally had to sucomb to it as i can't see an alternative and i'm no VB expert by any means! This is what i have so far:
View 7 Replies
View Related
Feb 22, 2014
How can I add the pause between count & boxes?
VB:
s.Speak count & "boxes for scanning!"
View 6 Replies
View Related