+ Reply to Thread
Results 1 to 7 of 7

VBA Script for Onclick Color Formatting

  1. #1
    Registered User
    Join Date
    12-01-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    VBA Script for Onclick Color Formatting

    Hey Guys,

    I need help making a simple script that will allow me to single click a cell (In column D only) and change the background color of the 2 cells to the right of the target. So if I click D4 then E4 and F4 will change to light yellow for example. I have a script that performs this function but it works in any cell on the worksheet. I need to limit this to single columns. Thanks in advance!

    -Sol

  2. #2
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: VBA Script for Onclick Color Formatting

    Look at intersect. The example in the help is very good. You can copy paste it.
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  3. #3
    Registered User
    Join Date
    12-01-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: VBA Script for Onclick Color Formatting

    I'm not sure where this example is located... could you provide a link?

  4. #4
    Registered User
    Join Date
    12-01-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: VBA Script for Onclick Color Formatting

    Maybe someone could give a little more detail... The cells I want to use this on all contain hyperlinks. A code that would change cell format based on activating a hyperlink may be even better than an intersect code. Examples would be great everyone. Thanks.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: VBA Script for Onclick Color Formatting

    Please Login or Register  to view this content.
    Code goes in the appropriate Sheet module:

    Adding Code to a Sheet module
    1. Copy the code from the post
    2. Right-click on the tab for the relevant sheet and select View Code. This opens the Visual Basic Editor (VBE) and shows the object module for the selected worksheet.
    3. Paste the code in the window
    4. Press Alt+Q to close the VBE and return to Excel
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: VBA Script for Onclick Color Formatting

    Hello Solar,

    You can add this macro to the worksheet that has the hyperlinks in column "D". It will color the cells in columns "E" and "F" in the same row as the hyperlink when the hyperlink is activated.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  7. #7
    Registered User
    Join Date
    12-01-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: VBA Script for Onclick Color Formatting

    These are both great macros guys. Thanks a bunch. One final question. What would be the correct language to incorporate a specific range in column 4? Such as If the target is D3:D19 then it would run the script and do nothing on the other cells in the column. Thanks again.

+ 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