+ Reply to Thread
Results 1 to 8 of 8

Can I assign a macro to a cell?

  1. #1
    Registered User
    Join Date
    04-22-2008
    Posts
    10

    Can I assign a macro to a cell?

    Hi,

    I'm a novice on Excel so any help, in lamens terms, is greatly appreciated.

    What I'm trying to do is create a spreadsheet where the user clicks on a cell, and a calendar pops up where they can select a date. The calendar then disappears and the date populates the cell.

    I've created the macro by following the instructions on the following website - http://www.fontstuff.com/vba/vbatut07.htm which works fine. I can call up the calendar either by pressing a button or right-clicking.

    I'm not sure if it's possible but what I want to happen is for the calendar to pop up when the user clicks on the cell, rather for them to have to right-click or click a button. Is this possible?

    Any help is appreciated.

    Regards, K-Rod.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    if you want the date in A1 then in the VB Editor double click on the sheet in the properties window and select Worksheet in the left hand drop down & make sure
    Worksheet_SelectionChange is displayed in the right hand one.

    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    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 K-Rod,

    This routine will display the calendar on any sheet in the workbook when you user clicks the cell.
    Please Login or Register  to view this content.
    How to Save a Workbook Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on any Worksheet's Name Tab
    3. Left Click on View Code in the pop up menu.
    4. Press ALT+F11 keys to open the Visual Basic Editor.
    5. Press CTRL+R keys to shift the focus to the Project Explorer Window
    6. Press the Down Arrow Key until ThisWorkbook is highlighted in blue.
    7. Press the Enter key to move the cursor to the Code Window
    8. Paste the macro code using CTRL+V
    9. Save the macro in your Workbook using CTRL+S

    Sincerely,
    Leith Ross

  4. #4
    Registered User
    Join Date
    04-22-2008
    Posts
    10
    Thanks guys.

    Leith - how do I copy the macro in step 1?

    Today was the first time I've ever used Visual Basic and I just followed the instructions in the link in my post, I don't really understand it. As long as it does what I want it to do I'm happy.

    Do I just apend the routine you wrote at the bottom of the code I've already got like this?
    Please Login or Register  to view this content.
    Once this is done, can I assign this macro to selected cells only?

    Many thanks.
    Last edited by Leith Ross; 04-22-2008 at 04:17 PM.

  5. #5
    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 K-Rod,

    The code I posted needs to go into the ThisWorkbook module in your project. If the other code is in this module then everything should work. If not, post your workbook so I can review it. You will need to zip it before attaching it to your post.

    Sincerely,
    Leith Ross

  6. #6
    Registered User
    Join Date
    04-22-2008
    Posts
    10
    Hi Leith,

    Sorry about this, but I've no idea how to use Visual Basic

    How do I zip my workbook?

    Your help is much appreciated.

    K-Rod.

  7. #7
    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 K-Rod,

    To zip your workbook, you will need a program like WinZip, PKZip, or Stuffit. Click the program name to visit the web site.

    To open the Visual Basic Editor or VBE, press the keys ALT+F11 after you have opened your workbook. This was in my post on how to install a Workbook Event macro.

    Sincerely,
    Leith Ross

  8. #8
    Registered User
    Join Date
    04-22-2008
    Posts
    10
    Hi Leith,

    I think I've done it, please see the attached.

    Thanks,

    K-Rod.
    Attached Files Attached Files

+ 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