+ Reply to Thread
Results 1 to 4 of 4

VBA toggle between colours on double click

  1. #1
    Registered User
    Join Date
    03-01-2012
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2010
    Posts
    64

    VBA toggle between colours on double click

    Hello folks

    Hope someone can help with this little query, I've created a calendar in Excel and I want to be able to double click on a cell to change the colour. If the cell is white I want it to turn to green, if the cell is green I want it to turn back to white. Furthermore if the cell is grey I don't want it to do anything. The cells in question contain the actual dates, and the purpose of this functionality is basically to allow the user to double click on the dates that they have booked off for vacation.

    Can anyone help please?

    Thanks to you all
    Kenny

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: VBA toggle between colours on double click

    Insert the following event macro in the worksheet code area:

    Please Login or Register  to view this content.
    Because it is worksheet code, it is very easy to install and automatic to use:
    1. right-click the tab name near the bottom of the Excel window
    2. select View Code - this brings up a VBE window
    3. paste the stuff in and close the VBE window
    If you have any concerns, first try it on a trial worksheet.

    If you save the workbook, the macro will be saved with it.


    To remove the macro:
    1. bring up the VBE windows as above
    2. clear the code out
    3. close the VBE window
    To learn more about macros in general, see:

    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    To learn more about Event Macros (worksheet code), see:

    http://www.mvps.org/dmcritchie/excel/event.htm

    Macros must be enabled for this to work!
    Gary's Student

  3. #3
    Registered User
    Join Date
    03-01-2012
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2010
    Posts
    64

    Re: VBA toggle between colours on double click

    Hi

    Thanks very much for this it works a treat! One question, how would I amend the code so I can use the RGB palette as opposed to ColorIndex?

    Thank you

    Kenny

  4. #4
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: VBA toggle between colours on double click

    I do not know. I have never used Interior.Color with RGB because most of my apps need to work for version of Excel from 2002 on up.

    I am interested in this topic.

    Please update this post if you find useful material.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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