LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default "OnCancel" syntax?

Some syntax given to me has error handling but I've found that that
doesn't work in a situation where the user can choose to cancel.
Cancelling while performing an operation just causes the process to
loop back so, in essence, the user is forced to continue.

Can an additional option for when a user hits cancel be added to this
great script (courtesy of JulieD; thanks Julie! <g). The error part
doesn't handle a cancel by the user.

------------------------------------------------------------------------------------------------
Sub insertrows()

Dim i As Long
Dim j As Long
Dim k As Long

On Error GoTo dontdothat
Do
i = InputBox("How many rows do you want to insert?", "Insert
Rows",
1)
Loop Until i < 0
Do
j = InputBox("At what row number do you want to start the
insertion?", "Insert Rows", 1)
Loop Until j < 0

ActiveSheet.Unprotect
k = j + i - 1
Range("" & j & ":" & k & "").Insert shift:=xlDown
j = j - 1
Range("A" & j & "").Select
Selection.AutoFill Destination:=Range("A" & j & ":A" & k &
""),
Type:=xlFillDefault
ActiveSheet.Protect
Exit Sub

dontdothat:
Resume

End Sub
------------------------------------------------------------------------------------------------

Thanks!

 
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
correct syntax for nesting "if", "and", and "vlookup"....if possib Christine Excel Worksheet Functions 4 January 2nd 09 10:43 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
syntax for "IF" commend to check for multiple empty cells bf comma Chris Excel Worksheet Functions 4 September 3rd 07 12:02 PM
Syntax to "OR" 3 "ISERROR" conditions Mike K Excel Worksheet Functions 6 July 22nd 06 04:18 PM
what is syntax for if(between range of dates,"Q1","Q2")? TLB Excel Worksheet Functions 3 December 6th 05 05:19 PM


All times are GMT +1. The time now is 07:14 PM.

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

About Us

"It's about Microsoft Excel"