Excel VBA Procedure Question

  • 18 years ago

    I have been using the built-in procedures for workbooks and worksheets (e.g. SelectionChange) for a while now and am observing a few limitations as to what I can achieve.

    How would I go about making my own worksheet/workbook procedures (and is it possible)?  For example I might want a before left click procedure for the worksheet.


  • 18 years ago

    Well, if you have VBA available, then you can write your own procedures.  It's should be available in EXCEL under  TOOLS/MACRO/VISUAL BASIC EDITOR.

    As to before click.  You might be able to do something with events or simply build a subroutine call into your click procedure that does your preprocessing.

    There are such things as declared events in VBA(activate by a RAISEEVENT EVENTNAME, but I haven't used them except in VB6, so not clear how to employ them in VBA.  I'll play with that.

    Not much help, but maybe a start.

  • 18 years ago

    ..I really meant whether or not it is possible to define my own procedure such as Worksheet_BeforeRightClick and get it to appear in the drop down menu for the worksheet in the VBA editor.


  • 18 years ago

    If I understand you correctly you are looking for is a way to add your own event to a workbook.  

    That would be something like adding an event called "CellClick", such that when you click on workbook in VB Editor's object selection, the Event selection will show 'CellClick' among the workbook's Events.  If this is what you are trying to do I don't think there is a way to do it.  There is nothing I can find within VBA help that indicates that you can add events to an existing object such as a workbook or sheet.  You can only write code within existing workbook, sheet , etc events.

    Not much help am I.javascript:smilie('')

  • 18 years ago

    You did understand me correctly!

    Guess I'll just have to plough on with the built in event procedures.  

    Cheers for your time all the same


Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“In theory, theory and practice are the same. In practice, they're not.”