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: 98
Default Error handler will not work correctly after [Ctrl] + [Break]

Hello all,

Using Excel 2002 (10.6501.6626) SP 3 on Windows XP Pro (5.1.2600) SP2

I do a lot of copying from SQL Server Query Analyzer/pasting to Excel. After pasting, my data is full of "NULL's" that I need to
replace. I've already come up with some code that will replace all of the NULL's giving you the option to paste data first or
replace NULL's on existing data. This code works just fine. I let this code run for 10 seconds and then do a [Ctrl] + [Break] or
else problems start to arise (the data I run this on can be as large as 40,000 rows X 30 columns, and then some).

I'm trying to adapt this code so that when I do a [Ctrl] + [Break], I will get some feed back. Right now, if I do the [Ctrl] +
[Break], my error handler does not work correctly (code will be posted at the bottom). I get the following message:
http://home.att.net/~ctbarbarin/file...ress_error.jpg. If I put a line of code in the sub routine that will raise an error, the
error handler works just fine (I was using If mrngCurrRange = "Nothing" Then<< when mrngCurrRange is declared as a range
variable--this Error-causing code is the 2nd line of code in this macro after variable declarations and "On Error GoTo...").

How can I get this error handler to work correctly on a [Ctrl] + [Break]? It works correctly on a legitimate error!
--
Thanks for any help anyone can provide,

Conan Kelly







Sub PasteReplaceNulls()
Dim pmbrResponse As VbMsgBoxResult
Dim pmbrAnswer As VbMsgBoxResult
Dim pstrPasteCell As String
Dim ptimTimer As Date
Dim mrngCurrRange As Range

On Error GoTo PasteReplaceNulls_Err

Application.EnableCancelKey = xlErrorHandler


' If mrngCurrRange = "Nothing" Then
' do stuff...
' End If

pstrPasteCell = "A2"

pmbrResponse = MsgBox("Do you want to Paste?", vbYesNoCancel + vbDefaultButton2 + vbQuestion, "Paste?")

If pmbrResponse = vbCancel Then
Exit Sub
ElseIf pmbrResponse = vbYes Then
pmbrAnswer = MsgBox("Data will be pasted starting in cell A2" & vbCrLf & vbCrLf & "Is this correct?", vbYesNoCancel +
vbQuestion, "Paste in A2")
If pmbrAnswer = vbCancel Then
Exit Sub
ElseIf pmbrAnswer = vbNo Then
pstrPasteCell = InputBox("Please enter the cell you would like pasting to begin:", "Paste Cell", pstrPasteCell)
End If
Range(pstrPasteCell).Select
ActiveSheet.Paste
End If


Selection.Replace "NULL", "", xlPart, xlByRows, False, False, False

Exit Sub

PasteReplaceNulls_Err:
MsgBox ActiveWorkbook.Name & vbCrLf & ActiveSheet.Name & vbCrLf & Selection.Address
Exit Sub

End Sub


 
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
How to make Ctrl-C, ctrl-V work in Office 2007 hj Excel Discussion (Misc queries) 1 June 23rd 09 01:09 PM
Form Err.Raise error not trapped by entry procedure error handler [email protected] Excel Programming 1 February 8th 06 10:19 AM
CTRL +BREAK Moiz, ABAC UK Excel Programming 1 November 29th 05 12:56 PM
error handler not working correctly Mike K Excel Programming 2 July 6th 05 12:21 PM
Can Not Get Macro to Break with CTRL-BREAK Break Me? Excel Programming 0 September 8th 04 03:15 AM


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