ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ignoring a sub routine (https://www.excelbanter.com/excel-programming/419612-ignoring-sub-routine.html)

SU123

ignoring a sub routine
 
i have two subroutines
1. on double click insert a line using Private Sub
Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

2. on enter resize cells (as some of my cells are merged and autofit does
not work) - using rivate Sub Worksheet_Change(ByVal Target As Range) function.

The issue i have is when calling function/sub 1, function/sub 2 is
automatically activated and causes an error.
is there a way that i can have function/sub one ignore function/sub 2.

Thanx in advance

Mauro Gamberini[_3_]

ignoring a sub routine
 
Try:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
'code
End Sub

--
---------------------------
Mauro Gamberini
http://www.riolab.org/
"SU123" ha scritto nel messaggio
...
i have two subroutines
1. on double click insert a line using Private Sub
Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

2. on enter resize cells (as some of my cells are merged and autofit does
not work) - using rivate Sub Worksheet_Change(ByVal Target As Range)
function.

The issue i have is when calling function/sub 1, function/sub 2 is
automatically activated and causes an error.
is there a way that i can have function/sub one ignore function/sub 2.

Thanx in advance




SU123

ignoring a sub routine
 
this wont actually work, because the issue becomes, by calling the second sub
routine, the relative place of the cursor changes and this makes the routines
very complex.

i did give it a try, and received the same error - which is caused due to
the relative cell position.

any other ideas.

"Mauro Gamberini" wrote:

Try:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
'code
End Sub

--
---------------------------
Mauro Gamberini
http://www.riolab.org/
"SU123" ha scritto nel messaggio
...
i have two subroutines
1. on double click insert a line using Private Sub
Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

2. on enter resize cells (as some of my cells are merged and autofit does
not work) - using rivate Sub Worksheet_Change(ByVal Target As Range)
function.

The issue i have is when calling function/sub 1, function/sub 2 is
automatically activated and causes an error.
is there a way that i can have function/sub one ignore function/sub 2.

Thanx in advance





Dave Peterson

ignoring a sub routine
 
If you've turned on "edit directly in the cell", then you'll be editing the cell
after you doubleclick on that cell.

If you hit the Escape key, then your second procedure doesn't fire, right?

You can add a line to stop going into edit mode after the doubleclick.

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
Cancel = True
'rest of code here
End Sub


SU123 wrote:

i have two subroutines
1. on double click insert a line using Private Sub
Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

2. on enter resize cells (as some of my cells are merged and autofit does
not work) - using rivate Sub Worksheet_Change(ByVal Target As Range) function.

The issue i have is when calling function/sub 1, function/sub 2 is
automatically activated and causes an error.
is there a way that i can have function/sub one ignore function/sub 2.

Thanx in advance


--

Dave Peterson

Bob Phillips[_3_]

ignoring a sub routine
 
Disable events

Application.EnableEvents = false

and reset to true after.

--
__________________________________
HTH

Bob

"SU123" wrote in message
...
this wont actually work, because the issue becomes, by calling the second
sub
routine, the relative place of the cursor changes and this makes the
routines
very complex.

i did give it a try, and received the same error - which is caused due to
the relative cell position.

any other ideas.

"Mauro Gamberini" wrote:

Try:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
'code
End Sub

--
---------------------------
Mauro Gamberini
http://www.riolab.org/
"SU123" ha scritto nel messaggio
...
i have two subroutines
1. on double click insert a line using Private Sub
Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

2. on enter resize cells (as some of my cells are merged and autofit
does
not work) - using rivate Sub Worksheet_Change(ByVal Target As Range)
function.

The issue i have is when calling function/sub 1, function/sub 2 is
automatically activated and causes an error.
is there a way that i can have function/sub one ignore function/sub 2.

Thanx in advance







SU123

ignoring a sub routine
 
Dave
i have that in the code already, but the issue occurs when i want to add a
new line.

when adding the new line, it checks the bolean, but as i select the cells to
copy and paste, it then tries to resize them (i.e. calls the 2nd procedure).

is there a way to add a bolean to the worksheet_change routine, as that i
believe would solve the issue.


"Dave Peterson" wrote:

If you've turned on "edit directly in the cell", then you'll be editing the cell
after you doubleclick on that cell.

If you hit the Escape key, then your second procedure doesn't fire, right?

You can add a line to stop going into edit mode after the doubleclick.

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
Cancel = True
'rest of code here
End Sub


SU123 wrote:

i have two subroutines
1. on double click insert a line using Private Sub
Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

2. on enter resize cells (as some of my cells are merged and autofit does
not work) - using rivate Sub Worksheet_Change(ByVal Target As Range) function.

The issue i have is when calling function/sub 1, function/sub 2 is
automatically activated and causes an error.
is there a way that i can have function/sub one ignore function/sub 2.

Thanx in advance


--

Dave Peterson


SU123

ignoring a sub routine
 

thanx Bob that worked a treat!
"Bob Phillips" wrote:

Disable events

Application.EnableEvents = false

and reset to true after.

--
__________________________________
HTH

Bob

"SU123" wrote in message
...
this wont actually work, because the issue becomes, by calling the second
sub
routine, the relative place of the cursor changes and this makes the
routines
very complex.

i did give it a try, and received the same error - which is caused due to
the relative cell position.

any other ideas.

"Mauro Gamberini" wrote:

Try:

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
'code
End Sub

--
---------------------------
Mauro Gamberini
http://www.riolab.org/
"SU123" ha scritto nel messaggio
...
i have two subroutines
1. on double click insert a line using Private Sub
Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

2. on enter resize cells (as some of my cells are merged and autofit
does
not work) - using rivate Sub Worksheet_Change(ByVal Target As Range)
function.

The issue i have is when calling function/sub 1, function/sub 2 is
automatically activated and causes an error.
is there a way that i can have function/sub one ignore function/sub 2.

Thanx in advance







Dave Peterson

ignoring a sub routine
 
It's not the doubleclicking that causes the trouble. It's what your code does.

But Bob answered that!

SU123 wrote:

Dave
i have that in the code already, but the issue occurs when i want to add a
new line.

when adding the new line, it checks the bolean, but as i select the cells to
copy and paste, it then tries to resize them (i.e. calls the 2nd procedure).

is there a way to add a bolean to the worksheet_change routine, as that i
believe would solve the issue.

"Dave Peterson" wrote:

If you've turned on "edit directly in the cell", then you'll be editing the cell
after you doubleclick on that cell.

If you hit the Escape key, then your second procedure doesn't fire, right?

You can add a line to stop going into edit mode after the doubleclick.

Option Explicit
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)
Cancel = True
'rest of code here
End Sub


SU123 wrote:

i have two subroutines
1. on double click insert a line using Private Sub
Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

2. on enter resize cells (as some of my cells are merged and autofit does
not work) - using rivate Sub Worksheet_Change(ByVal Target As Range) function.

The issue i have is when calling function/sub 1, function/sub 2 is
automatically activated and causes an error.
is there a way that i can have function/sub one ignore function/sub 2.

Thanx in advance


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 02:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com