Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Stop
I always seem to come across interesting things as I make up new
workbooks. I'm using the following code to allow user to step to the left: ActiveCell.Offset(0, -1).Select Butt when user gets to A1, if the button is pushed again by accident, an error box comes up because the first cell is reached: Run-time error '1004': Application-defined or object-defined error Is there any way to stop this error popping up? Any advice re this? Even a message saying "you can't go any further to the left", heck, whatever works <g. Thanks. :oD |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Stop
maybe this
Sub test() If ActiveCell.Column < 1 Then ActiveCell.Offset(0, -1).Select End If end sub -- Gary "StargateFan" wrote in message ... I always seem to come across interesting things as I make up new workbooks. I'm using the following code to allow user to step to the left: ActiveCell.Offset(0, -1).Select Butt when user gets to A1, if the button is pushed again by accident, an error box comes up because the first cell is reached: Run-time error '1004': Application-defined or object-defined error Is there any way to stop this error popping up? Any advice re this? Even a message saying "you can't go any further to the left", heck, whatever works <g. Thanks. :oD |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Stop
You have 2 options:
- Check where the active cell is first. If ActiveCell.Column 1 Then ActiveCell.Offset(0, -1).Select - Do it anyway and ignore the error, as (in this case) no damage is done or propagated by the error. On Error Resume Next ActiveCell.Offset(0, -1).Select On Error GoTo 0 NickHK "StargateFan" wrote in message ... I always seem to come across interesting things as I make up new workbooks. I'm using the following code to allow user to step to the left: ActiveCell.Offset(0, -1).Select Butt when user gets to A1, if the button is pushed again by accident, an error box comes up because the first cell is reached: Run-time error '1004': Application-defined or object-defined error Is there any way to stop this error popping up? Any advice re this? Even a message saying "you can't go any further to the left", heck, whatever works <g. Thanks. :oD |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Stop
On Thu, 12 Apr 2007 00:21:55 -0400, "Gary Keramidas"
<GKeramidasATmsn.com wrote: maybe this Sub test() If ActiveCell.Column < 1 Then ActiveCell.Offset(0, -1).Select End If end sub Super. It seems to work perfectly. I keep going left till it stops yet no error comes up which is great. Thanks. :oD Gary "StargateFan" wrote in message .. . I always seem to come across interesting things as I make up new workbooks. I'm using the following code to allow user to step to the left: ActiveCell.Offset(0, -1).Select Butt when user gets to A1, if the button is pushed again by accident, an error box comes up because the first cell is reached: Run-time error '1004': Application-defined or object-defined error Is there any way to stop this error popping up? Any advice re this? Even a message saying "you can't go any further to the left", heck, whatever works <g. Thanks. :oD |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Stop
On Thu, 12 Apr 2007 12:31:55 +0800, "NickHK"
wrote: You have 2 options: - Check where the active cell is first. If ActiveCell.Column 1 Then ActiveCell.Offset(0, -1).Select - Do it anyway and ignore the error, as (in this case) no damage is done or propagated by the error. On Error Resume Next ActiveCell.Offset(0, -1).Select On Error GoTo 0 Thanks! What is the difference, pls, between the 2nd code above and Gary's solution? Sub test() If ActiveCell.Column < 1 Then ActiveCell.Offset(0, -1).Select End If end sub Thanks. :oD NickHK "StargateFan" wrote in message .. . I always seem to come across interesting things as I make up new workbooks. I'm using the following code to allow user to step to the left: ActiveCell.Offset(0, -1).Select Butt when user gets to A1, if the button is pushed again by accident, an error box comes up because the first cell is reached: Run-time error '1004': Application-defined or object-defined error Is there any way to stop this error popping up? Any advice re this? Even a message saying "you can't go any further to the left", heck, whatever works <g. Thanks. :oD |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Stop
The 2nd option executes the code anyway, but any error raised is simply
ignored and code continues. In Gary's code, the potentially error causing is not executed if it would raise an error. NickHK "StargateFan" wrote in message ... On Thu, 12 Apr 2007 12:31:55 +0800, "NickHK" wrote: You have 2 options: - Check where the active cell is first. If ActiveCell.Column 1 Then ActiveCell.Offset(0, -1).Select - Do it anyway and ignore the error, as (in this case) no damage is done or propagated by the error. On Error Resume Next ActiveCell.Offset(0, -1).Select On Error GoTo 0 Thanks! What is the difference, pls, between the 2nd code above and Gary's solution? Sub test() If ActiveCell.Column < 1 Then ActiveCell.Offset(0, -1).Select End If end sub Thanks. :oD NickHK "StargateFan" wrote in message .. . I always seem to come across interesting things as I make up new workbooks. I'm using the following code to allow user to step to the left: ActiveCell.Offset(0, -1).Select Butt when user gets to A1, if the button is pushed again by accident, an error box comes up because the first cell is reached: Run-time error '1004': Application-defined or object-defined error Is there any way to stop this error popping up? Any advice re this? Even a message saying "you can't go any further to the left", heck, whatever works <g. Thanks. :oD |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How stop the "started office live" pop-up to stop. it is checked | Excel Discussion (Misc queries) | |||
Stop % in red | Excel Worksheet Functions | |||
How do I stop other circles in other cells to stop selecting? | Excel Worksheet Functions | |||
How do I stop other circles in other boxes to stop selecting? | Excel Worksheet Functions | |||
Macro: With Stop it works. Without Stop it doesn't. | Excel Programming |