Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Ambiguous error
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _ Cancel As Boolean) Dim icbc As Object For Each icbc In Application.CommandBars("cell").Controls If icbc.Tag = "octane" Then icbc.Delete Next icbc With Application.CommandBars("cell").Controls _ .Add(Type:=msoControlButton, befo=6, _ temporary:=True) .Caption = "Octane" .OnAction = "octane" .Tag = "octane" End With End Sub I copied and pasted this from the VB help section in excel. It works good by itself. If I copy and paste again and change all the "octanes" to something else and change the (what I think is the name) of the Sub ever so slightly it doesn't work. Can you have more than one sub-routine in the worksheet code? There must be a way to modify the name of the Sub and keep it working in unison with the original. Beats me. -- famdamly ------------------------------------------------------------------------ famdamly's Profile: http://www.excelforum.com/member.php...o&userid=29382 View this thread: http://www.excelforum.com/showthread...hreadid=516779 |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Ambiguous error
You cannot change the name of the procedure as that is known to Excel, and
it must be exact. You have more than one logic path, but you put that all in the same procedure, such as If condition1 Then action1 Elseif condition2 Then action2 EndIf -- HTH Bob Phillips (remove nothere from email address if mailing direct) "famdamly" wrote in message ... Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, _ Cancel As Boolean) Dim icbc As Object For Each icbc In Application.CommandBars("cell").Controls If icbc.Tag = "octane" Then icbc.Delete Next icbc With Application.CommandBars("cell").Controls _ Add(Type:=msoControlButton, befo=6, _ temporary:=True) Caption = "Octane" OnAction = "octane" Tag = "octane" End With End Sub I copied and pasted this from the VB help section in excel. It works good by itself. If I copy and paste again and change all the "octanes" to something else and change the (what I think is the name) of the Sub ever so slightly it doesn't work. Can you have more than one sub-routine in the worksheet code? There must be a way to modify the name of the Sub and keep it working in unison with the original. Beats me. -- famdamly ------------------------------------------------------------------------ famdamly's Profile: http://www.excelforum.com/member.php...o&userid=29382 View this thread: http://www.excelforum.com/showthread...hreadid=516779 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Ignore error msgs in formula references | Excel Discussion (Misc queries) | |||
Error trapped only while stepping through the code - Not triggered when run | Excel Discussion (Misc queries) | |||
Error trapped only while stepping through the code - Not triggered when run | Excel Discussion (Misc queries) | |||
Problem with VBA returning the contents of a long formula. | Excel Discussion (Misc queries) | |||
ERROR | Excel Discussion (Misc queries) |