+ Reply to Thread
Results 1 to 2 of 2

running vba on active cell selection

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-23-2007
    Location
    Suffolk, UK
    Posts
    298

    running vba on active cell selection

    hello,

    i have a holiday planner that i'm working on, i have a cell range of B15:C155 the has the days start and finish B & C, i already have a calendar within the workbook but cannot seem to get it to activate when a cell within the range is selected, here is the vba for the calendar

    Sub OpenCalendar()
    ' Displays the UserForm and calendar
    ' Shortcuts should be made to this procedure
        frmCalendar.Show
    End Sub
    Option Explicit
    
    
    Private Sub Workbook_Open()
        Dim NewControl As CommandBarControl
    ' Assign shortcut to display calendar on SHIFT+CTRL+C
        Application.OnKey "+^{C}", "Module1.OpenCalendar"
    ' Add item to shortcut menu on open
        On Error Resume Next
        Application.CommandBars("Cell").Controls("Insert Date").Delete
        On Error GoTo 0
        Set NewControl = Application.CommandBars("Cell").Controls.Add
        With NewControl
            .Caption = "Insert Date"
            .OnAction = "Module1.OpenCalendar"
            .BeginGroup = True
        End With
    End Sub
    
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    ' Delete item from shortcut menu on close
        On Error Resume Next
        Application.CommandBars("Cell").Controls("Insert Date").Delete
    End Sub
    can anyone help me??

    thanks reg
    Last edited by reggie1000; 08-15-2008 at 12:28 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello reggie1000,

    It would be easier to help you if your code and question were related. Your question is about cell selection and the code deals with modifying the cell context menu. It would be best if post your workbook for review. If you are using Excel 2007, save the workbook in 2003 format also.

    Sincerely,
    Leith Ross

+ 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