preventing comboboxes from triggering when sheet copied

G

gtslabs

I have 2 comboboxes that are triggering when ever I copy the sheet to
a new sheet or delete a sheet. This is generating errors. I also
have a workshet_selectionCange and have isolated that this is
triggering the 2 combo routines even though the combos are based on a
Click event.
The linked cell and reference range of the 2 comboboxes do not refer
to the cells in the module below. The combobox code is in each sheet
not a module.

How can I modify my code to prevent the combos from triggering when a
new sheet is added, deleted, etc.


in the worksheet:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
jfactor
End Sub



in a module:
Sub jfactor()
'Application.EnableEvents = False
If Cells(27, 2).Value = 0 Then
Cells(28, 2).Value = ""
ElseIf Cells(28, 2) = "" Then '<==== ADD THIS CODE
Cells(28, 2).Value = 1000 'whatever the default value is
End If
' Application.EnableEvents = True
End Sub
 
T

The Code Cage Team

gtslabs;160877 said:
I have 2 comboboxes that are triggering when ever I copy the sheet to
a new sheet or delete a sheet. This is generating errors. I also
have a workshet_selectionCange and have isolated that this is
triggering the 2 combo routines even though the combos are based on a
Click event.
The linked cell and reference range of the 2 comboboxes do not refer
to the cells in the module below. The combobox code is in each sheet
not a module.

How can I modify my code to prevent the combos from triggering when a
new sheet is added, deleted, etc.


in the worksheet:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
jfactor
End Sub



in a module:
Sub jfactor()
'Application.EnableEvents = False
If Cells(27, 2).Value = 0 Then
Cells(28, 2).Value = ""
ElseIf Cells(28, 2) = "" Then '<==== ADD THIS CODE
Cells(28, 2).Value = 1000 'whatever the default value is
End If
' Application.EnableEvents = True
End Sub

How are you copying the sheet?, you could use the before right click
event on the worksheet and use the Application.enableevents=False...etc,
in the module you displayed you have them correctly positioned but
stetted out with the ' which just makes them comment lines!


--
The Code Cage Team

Regards,
The Code Cage Team
'The Code Cage' (http://www.thecodecage.com)
 
G

gtslabs

gtslabs;160877 Wrote:









How are you copying the sheet?, you could use the before right click
event on the worksheet and use the Application.enableevents=False...etc,
in the module you displayed you have them correctly positioned but
stetted out with the ' which just makes them comment lines!

--
The Code Cage Team

Regards,
The Code Cage Team
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
The Code Cage Team's Profile:http://www.thecodecage.com/forumz/member.php?userid=2
View this thread:http://www.thecodecage.com/forumz/showthread.php?t=44724- Hide quoted text -

- Show quoted text -

We when I removed the comment lines I was not able to copy a sheet tab
to a new one.
I thought that code was the problem but I still get the errors.
The only way I can get it from not firing the 2 comboboxes is when I
am in the deisgn Mode.
Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top