+ Reply to Thread
Results 1 to 4 of 4

VBA - Click to highlight cell/range

  1. #1
    Registered User
    Join Date
    11-07-2017
    Location
    CANADA
    MS-Off Ver
    2010
    Posts
    44

    VBA - Click to highlight cell/range

    Hi,

    I'm trying to do the following on the attached "shift spreadsheet";
    • Click on either a single cell or select a range in the table to highlight the cells green
    • When left clicking on a cell or selecting a range, input "1"
    • When right clicking on a cell, input "0.5"
    • Clicking on the same cells will remove the highlight and value
    • Check the other columns for the day and highlight any cells that don't have coverage red
    • Calculate the total number of hours in the last column

    I've found a number of formulas that do one or the other but I haven't been able to combine them to get the desired outcome.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    11-20-2007
    Location
    Felixstowe, England
    MS-Off Ver
    Excel 2013, 2019
    Posts
    217

    Re: VBA - Click to highlight cell/range

    Have you done any research, or programming attempts at all? If you want advice when you get stuck, then everyone will help out.

  3. #3
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: VBA - Click to highlight cell/range

    That's a lot to cram in! Firstly, you can probably achieve the highlight using conditional formulas. For range C4:Z79 use the following formula to colour cells green:

    Please Login or Register  to view this content.
    And to highlight the hours when there is no cover, use the following formula on range C3:Z69:

    Please Login or Register  to view this content.
    Then in AA4 you can use the formula to calculate total hours:

    Please Login or Register  to view this content.
    And copy that down. Finally, to get highlighting etc. to put in the values you want, try the following code in the worksheet module:

    Please Login or Register  to view this content.
    See attached.

    WBD
    Attached Files Attached Files
    Office 365 on Windows 11, looking for rep!

  4. #4
    Registered User
    Join Date
    11-07-2017
    Location
    CANADA
    MS-Off Ver
    2010
    Posts
    44

    Re: VBA - Click to highlight cell/range

    Quote Originally Posted by WideBoyDixon View Post
    That's a lot to cram in! Firstly, you can probably achieve the highlight using conditional formulas. For range C4:Z79 use the following formula to colour cells green:
    This is perfect, thank you very much!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Function to click cell and highlight row
    By eberns65 in forum Excel General
    Replies: 1
    Last Post: 07-19-2019, 04:09 PM
  2. Replies: 2
    Last Post: 05-06-2018, 09:45 AM
  3. [SOLVED] Expand a range when you click any cell in the last line of the range
    By Dickie Dunkin in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-17-2016, 03:32 PM
  4. Replies: 4
    Last Post: 04-12-2015, 02:47 AM
  5. Problem with Code to "Click to highlight cell"
    By lp116 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2014, 03:11 PM
  6. I click on one cell and multiples will highlight
    By Gupper in forum Excel General
    Replies: 4
    Last Post: 09-03-2011, 03:20 AM
  7. Replies: 5
    Last Post: 05-27-2005, 02:05 PM

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