+ Reply to Thread
Results 1 to 7 of 7

Help with code for a command button that changes strikethrough cells green

  1. #1
    Registered User
    Join Date
    01-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    15

    Help with code for a command button that changes strikethrough cells green

    Hi,

    This code works but I want it to be slightly different.

    Here is what I want the code to do:
    When I hit the command button, I want any cells from K5:Y501 that have a strikethrough to turn green.

    The code below does this but by selecting all of the cells in the range. How can I get the same outcome without the range being selected?

    Also I would like there to be no color when the strikethrough is gone

    I would like this to override conditional formatting if possible.

    Here is the code I have:

    Please Login or Register  to view this content.

    Thanks!
    Last edited by SerraAngel; 11-04-2014 at 07:32 PM. Reason: Added info

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Help with code for a command button that changes strikethrough cells green

    Hi, SerraAngel,

    I would like this to override conditional formatting if possible.
    You would need to inform us if there is any CF involved.

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    08-17-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    132

    Re: Help with code for a command button that changes strikethrough cells green

    Hi SerraAngel,

    Try this:
    Please Login or Register  to view this content.
    Regards,

  4. #4
    Registered User
    Join Date
    01-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    15

    Re: Help with code for a command button that changes strikethrough cells green

    Wow thanks for the quick response HaHoBe....that code worked!

    As far as the conditional formatting:

    I have written a formula so if I type a value in I2 then anything that matches that value in cells K5:y501 turn red. However, I do not want them to turn red if I have already used a strikethrough

    Here is the formula I used for the conditional formatting:

    =AND(K5<>"", NOT(ISERROR(MATCH(K5,$I$2,0))))

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Help with code for a command button that changes strikethrough cells green

    Hi, SerraAngel,

    I would rethink the approach of using CF and a CommandbUtton and use the Change-Event for the range behidn the sheet and integrate the CF into the code as well. Are there formulas in the cells or values only which are entered directly?

    Ciao,
    Holger

  6. #6
    Registered User
    Join Date
    01-01-2013
    Location
    United States
    MS-Off Ver
    Excel 2013
    Posts
    15

    Re: Help with code for a command button that changes strikethrough cells green

    Sales Follow up tasks.xlsm

    Here is the spreadsheet I am working on. You can enter a date in column J and columns K:Y will auto fill with dates according to number of days after initial contact (row 3.) There is a formula located in cells K5:Y501 for this.

    I wanted to be able to see certain dates so if you type a date into cell I2 it will turn any matching cells from K5:Y501 red using conditional formatting.

    I wanted to be able to signify when I have completed a task so I was planning on putting a strikethrough on a date (by hitting ctrl+5) and then hit the command button to turn them green.

    However when I type a date in I2 it will turn red even when there is a strikethrough signifying completion.

    If you know a better way that would be greatly appreciated

    Thanks

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Help with code for a command button that changes strikethrough cells green

    Hi, SerraAngel,

    there are 2 caveats which sort of make the problem a bit harder to solve. You have used CF for one condition, and AFAIK you may use CF to strike through but not to reckognize if a cell font is like that. On the other hand you may do a lot of things directly with VBA and events behind the sheet but the changes to the font or the colours inside a cell won´t fire an event in Excel VBA directly.

    So you should either consider to write a function to check the contents and use this in the CF as an additional rule or use events but restrict these to make an enter for each cell after any cell font change in order to fire the event in order to work only with one event.

    Ciao,
    Holger

+ 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. Replies: 5
    Last Post: 06-18-2014, 02:25 PM
  2. Create a command button with code with a command button
    By jakara in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2013, 01:28 PM
  3. Code for a master command button to change the backcolor of multiple command buttons?
    By panttherm5 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2012, 10:11 PM
  4. [SOLVED] vba code, command bar, command bar button, one button works but not two
    By amazingg64 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-13-2012, 09:55 AM
  5. Command Button Code to Delete Unprotected Cells Only
    By macky1730 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-01-2011, 04:30 AM

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