Loading
Ozgrid Excel Help & Best Practices Forums

Excel Training / Excel Dashboards Reports



Results 1 to 8 of 8

Thread: Click In Cell To Run Macro

  1. #1
    Join Date
    10th February 2007
    Posts
    7

    Click In Cell To Run Macro

    Is it possible to click in a cell in Excel to run a macro? assign macro to
    cell type thing.

    thanks

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    26th January 2003
    Location
    Derbyshire,UK
    Posts
    19,833

    Re: Click In Cell To Run Macro

    You can't assign a macro to cell, you could activate it by various worksheet events such as Double Click
    Hope that Helps

    Roy

    New users should read the Forum Rules before posting

    For free Excel tools & articles visit my web site

    If I have helped you and you feel like putting your hand in your pocket please make a donation to Children in Need

    RoyUK's Web Site

    royUK's Database Form

    Where to paste code from the Forum

    About me.

  3. #3
    Join Date
    10th February 2007
    Posts
    7

    Re: Click In Cell To Run Macro

    Thanks for that.

    How do you assign it to a double click event?

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    26th January 2003
    Location
    Derbyshire,UK
    Posts
    19,833

    Re: Click In Cell To Run Macro

    Open the VBE (Alt+F11) and then double click the Sheet in the Project Explorer the code applies to. This is where the code MUST be placed.

    VB:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) 
        Call MyMacro 
    End Sub 
    
    
    Replace MyMacro with your macro's name
    Hope that Helps

    Roy

    New users should read the Forum Rules before posting

    For free Excel tools & articles visit my web site

    If I have helped you and you feel like putting your hand in your pocket please make a donation to Children in Need

    RoyUK's Web Site

    royUK's Database Form

    Where to paste code from the Forum

    About me.

  5. #5
    Join Date
    10th February 2007
    Posts
    7

    Re: Click In Cell To Run Macro

    thanks so much for that. you have saved my life!!!!

    Excel Video Tutorials / Excel Dashboards Reports


  6. #6
    Join Date
    10th February 2007
    Posts
    7

    Re: Click In Cell To Run Macro

    can you use this method for different macros and different cells etc... if i was to double click in a1 then e1 is pink, if i double click in b1 then f1 is red?? i was trying with an if statement using the activecell range but can get it working.

    Excel Video Tutorials / Excel Dashboards Reports


  7. #7
    Join Date
    26th January 2003
    Location
    Derbyshire,UK
    Posts
    19,833

    Re: Click In Cell To Run Macro

    is this what you mean?
    VB:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) 
        Dim i As Integer 
        If Target.Cells.Count > 1 Then Exit Sub 
        i = Target.Column 
         
        Select Case i 
        Case 1: ActiveCell.Offset(0, 5).Interior.ColorIndex = 5 
        Case 2: ActiveCell.Offset(0, 5).Interior.ColorIndex = 3 
        Case 3: ActiveCell.Offset(0, 5).Interior.ColorIndex = 12 
        End Select 
         
    End Sub 
    
    
    Hope that Helps

    Roy

    New users should read the Forum Rules before posting

    For free Excel tools & articles visit my web site

    If I have helped you and you feel like putting your hand in your pocket please make a donation to Children in Need

    RoyUK's Web Site

    royUK's Database Form

    Where to paste code from the Forum

    About me.

  8. #8
    Join Date
    10th February 2007
    Posts
    7

    Re: Click In Cell To Run Macro

    thats great.thanks sooooooooooooooo much

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Replies: 2
    Last Post: February 7th, 2008, 17:56
  2. Change Cell Color On Click And Reverse Macro
    By brg1266 in forum Excel General
    Replies: 5
    Last Post: May 5th, 2007, 02:57
  3. Macro: Go To Active Cell Topic on Button Click
    By gert steegmans in forum Excel General
    Replies: 4
    Last Post: December 7th, 2006, 00:46
  4. Run Macro On Double Click
    By TJE in forum Excel General
    Replies: 2
    Last Post: October 26th, 2006, 15:56
  5. start macro when click...
    By sal21 in forum Excel General
    Replies: 2
    Last Post: March 9th, 2004, 22:09

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
  •  
porno