Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
"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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
What is Error "Method "Paste" of object "_Worksheet" failed? | Excel Programming | |||
Interactive Chart/ "Method Cells of object '_global' failed" | Excel Programming | |||
Excel-VBA: "1004 - Method 'Range' of object '_Global' failed" | Excel Programming | |||
Adding named range gives error "method range of object _Global failed " | Excel Programming | |||
"Run-time error '1004'" Method 'Range' of object '_global' failed. | Excel Programming |