Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default "Method 'Selection' of object '_Global' failed" error

Hello all,

I'm trying to run some code from an error handler and I keep getting this message:

http://home.att.net/~ctbarbarin/file...ress_error.jpg

This happens whether I call a sub procedure from with in the error handler or whether I put the code directly in the error handler.

I works just fine if I run the sub procedure all by itself, but I can't get it to work from the error handler.

How can I get this to run from within the error handler?


Here is the code:


(error handler call and sub procedure)

PasteReplaceNulls_Err:
DisplayProgress
Exit Sub

End Sub

Sub DisplayProgress()
Dim plngFirstRow As Long
Dim plngFirstCol As Long
Dim plngCurrRow As Long
Dim plngCurrCol As Long
Dim plngCurrCell As Long
Dim plngTotalCells As Long

plngTotalCells = Selection.Cells.Count
plngFirstRow = Selection.Cells(1).Row
plngFirstCol = Selection.Cells(1).Column
plngCurrRow = Selection.Find("NULL", ActiveCell, xlFormulas).Row
plngCurrCol = Selection.Find("NULL", ActiveCell, xlFormulas).Column

plngCurrCell = ((plngCurrRow - plngFirstRow) * Selection.Columns.Count) + (plngCurrCol - plngFirstCol) + 1
MsgBox "Progress: " & FormatPercent(plngCurrCell / plngTotalCells, 2, vbTrue)

End Sub




(or error handler code)

PasteReplaceNulls_Err:
plngTotalCells = Selection.Cells.Count
plngFirstRow = Selection.Cells(1).Row
plngFirstCol = Selection.Cells(1).Column
plngCurrRow = Selection.Find("NULL", ActiveCell, xlFormulas).Row
plngCurrCol = Selection.Find("NULL", ActiveCell, xlFormulas).Column

plngCurrCell = ((plngCurrRow - plngFirstRow) * Selection.Columns.Count) + (plngCurrCol - plngFirstCol) + 1
MsgBox "Progress: " & FormatPercent(plngCurrCell / plngTotalCells, 2, vbTrue)
Exit Sub

End Sub

(Variable names were declared at the top of the sub)



--
Thanks for any help anyone can provide,

Conan Kelly


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
What is Error "Method "Paste" of object "_Worksheet" failed? vat Excel Programming 7 February 17th 06 08:05 PM
Interactive Chart/ "Method Cells of object '_global' failed" Sibilia[_6_] Excel Programming 3 July 1st 05 06:45 PM
Excel-VBA: "1004 - Method 'Range' of object '_Global' failed" THA Excel Programming 1 May 18th 05 09:18 AM
Adding named range gives error "method range of object _Global failed " Gunnar Johansson Excel Programming 3 August 10th 04 01:54 PM
"Run-time error '1004'" Method 'Range' of object '_global' failed. haisat[_2_] Excel Programming 0 October 20th 03 12:13 PM


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