#1   Report Post  
Posted to microsoft.public.excel.misc
famdamly
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ignore error msgs in formula references gharden Excel Discussion (Misc queries) 4 June 17th 05 12:14 AM
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 7 March 7th 05 06:29 PM
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 0 February 28th 05 06:26 PM
Problem with VBA returning the contents of a long formula. [email protected] Excel Discussion (Misc queries) 2 February 23rd 05 12:14 AM
ERROR Pinto1uk Excel Discussion (Misc queries) 1 February 8th 05 03:15 AM


All times are GMT +1. The time now is 09:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"