+ Reply to Thread
Results 1 to 2 of 2

Ambiguous error

  1. #1
    Registered User
    Join Date
    12-05-2005
    Location
    WA
    Posts
    83

    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, before:=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.

  2. #2
    Bob Phillips
    Guest

    Re: 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" <[email protected]> wrote in
    message news:[email protected]...
    >
    > 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, before:=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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1