+ Reply to Thread
Results 1 to 3 of 3

VBA to change strike through to Red without changing the font color (Black)

Hybrid View

  1. #1
    Registered User
    Join Date
    08-01-2015
    Location
    CA
    MS-Off Ver
    2013
    Posts
    12

    VBA to change strike through to Red without changing the font color (Black)

    This macro changes both the strike through and the Font color to Red. I only want the strike through to be in Red and the font color to remain black.

    Sub changestrikethroughtoRed()
    Dim X As Long
    Dim cel As Range
    Dim ch As Font
    Dim vst, vun
    Range("C4:c50").Select
    For Each cel In Selection
    
    X = FntFormat(cel.Font)
    If X = 0 Then
    For i = 1 To Len(cel)
    cel.Characters(i, 1).Font.ColorIndex = _
    FntFormat(cel.Characters(i, 1).Font)
    Next
    Else
    cel.Font.ColorIndex = X
    End If
    Next
    End Sub
    
    Function FntFormat(fnt As Font) As Long
    Dim v1, v2
    Dim X As Long
    v1 = fnt.Strikethrough
    v2 = (fnt.Underline <> xlUnderlineStyleNone)
    If IsNull(v1) Or IsNull(v2) Then
    X = 0
    Else
    X = xlAutomatic
    If v1 Then X = 3
    If v2 Then
    If X > 0 Then X = 13 Else X = 5
    End If
    End If
    FntFormat = X
    End Function

    Thanks!
    Last edited by sjs4952; 12-22-2018 at 02:23 PM. Reason: Tags around code

  2. #2
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,740

    Re: VBA to change strike through to Red without changing the font color (Black)

    As far as I'm aware that cannot be done. The strikethrough is part of the font & as such they will both have the same colour

  3. #3
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA to change strike through to Red without changing the font color (Black)

    Hello sjs4952,

    Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 6)
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

+ 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. Shortcut for changing the color from black font to red
    By guest928 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-04-2017, 11:13 AM
  2. Changing all blue color numbers/texts to black color in cells...
    By dhyun3 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-05-2012, 10:17 AM
  3. Change the font color to black in the entire workbook
    By fatalcore in forum Excel General
    Replies: 2
    Last Post: 03-31-2011, 02:30 AM
  4. Replies: 59
    Last Post: 07-11-2010, 06:12 PM
  5. Changing font color based on change from previous value
    By dgtvr in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-18-2008, 04:25 PM
  6. getting font color to stay black!
    By buckfoston in forum Excel General
    Replies: 1
    Last Post: 06-02-2006, 05:45 PM
  7. Fill Color and Font Color stay Black and White
    By Hors Categorie in forum Excel General
    Replies: 1
    Last Post: 05-10-2005, 07:20 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