Consulting

Page 1 of 2 1 2 LastLast
Results 1 to 20 of 26

Thread: Run a Macro when you click on a cell

  1. #1

    Run a Macro when you click on a cell

    Hi everyone,

    I need some help with Excel. I am trying to run a macro which is for a calendar pop up to run automatically when a cell is clicked on.

    When I press Alt + F8 it shows my macro and it says that is called Personal.xls!OpenCalendar.

    I need to this macro to run whenever a cell is clicked on in 'D'

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    calendar controls will give you problems if you are sending it to other people. they may not have the calendar control installed.....

    This can be done though.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    This is for a spreadsheet that I was asked to make for my company. It won't be sent to anyone there are only a hnadful of people that are working on this spreadsheet. I created a new form and created the calendar within that and it is only linked to this workbook so I don't see that being an issue. I just need the popup to come up when I click on that column. What can I do?

  4. #4
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    This is sheet change code so it needs to go in the code module for the sheet. It is set for column 1 or A

    the calendar control will have to be on userform1 or you will have to change that part in the code.

    [VBA]Option Explicit
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Application.EnableEvents = False
    If Target.Column = 1 Then
    UserForm1.Show
    End If
    Application.EnableEvents = True
    End Sub[/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  5. #5
    I put in the code and I changed my form to Userform1 but when I click nothing happens. I changed userform1 eveywhere in my project. Nothing happens when I click anywhere. I'm really sorry for being a pest. I really appreciate your help.

  6. #6
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Did you put it in the module for sheet that want it to work on?

    example attached.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  7. #7
    yes i went to sheet1 and right clicked and view code

  8. #8
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Post your workbook, it will ease matters.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  9. #9
    I am just testing out some ideas. I hope this will have all my stuff i did in the module thing with it

  10. #10
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    There is no userform or calendar control in the workbook you posted.


    Try it now


    Column A
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  11. #11
    THIS IS weird nothing happens when I click anywhere.

  12. #12
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Click in column A
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  13. #13
    i closed everything i had open and ran the one you sent me. thank you so much for your help!!!!!

  14. #14
    VBAX Mentor
    Joined
    Jun 2004
    Posts
    363
    Location
    Sorry if I'm misreading your request. Try the attached. It should launch your OpenCalendar macro contained in your Personal.xls file when you click anywhere in the D column.

  15. #15
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    I missed the personal.xls part. Thanks mbarron. You will have to add it to everyone's personal.xls that uses it. You probably should just leave it in the workbook......
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  16. #16
    thanks a lot guys. I think its better as well if I just include it in the workbook it self. Can I change the Personal.xls to be just in this workbok>?

  17. #17
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    export the userform out of personal and then import it into your workbook....
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  18. #18
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Then you can delete it from your personal.xls
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  19. #19
    I'M BACK AGAIN!

    I have started to put the spreadsheet together. And there is a section where there is a i have to get a due date from a date submitted. I have got that fine but i have to fill down the formula however when I do this becasue the date fields it is showing a date of 1/11/1900. Is there an easy way for me to hide this until a number is populated in the corresponding field?

    Attached is my spreadsheet column 2 populates column 16.

  20. #20
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    =IF(B2<>"",(WORKDAY(B2,8)),"")

    In row 2 and drag down
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

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