Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-10-2024, 09:35 AM
NitroPress NitroPress is offline Macro to toggle strikethrough? Windows 11 Macro to toggle strikethrough? Office 2016
Novice
Macro to toggle strikethrough?
 
Join Date: Nov 2019
Posts: 22
NitroPress is on a distinguished road
Default Macro to toggle strikethrough?

Trivial in Word, but this has completely eluded me in Excel, for some reason —




I use strikethrough to keep track of values accounted for elsewhere and frequently strike and un-strike cells in the process. Unlike Word, Excel buries the format control a bit, making it difficult to access and apply/unapply.


I need a simple VBA action/macro that will toggle strikethrough on and off on a selected cell. This could be done with a cell style, but as I apply it to a variety of formatted cells, it needs to work without affecting any other style setting.


Ad(thanks)vance!
Reply With Quote
  #2  
Old 03-11-2024, 08:53 AM
Logit Logit is offline Macro to toggle strikethrough? Windows 10 Macro to toggle strikethrough? Office 2007
Expert
 
Join Date: Jan 2017
Posts: 533
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

The following is already built into Excel :

Code:
CTRL / 5
Reply With Quote
  #3  
Old 03-11-2024, 09:39 AM
NitroPress NitroPress is offline Macro to toggle strikethrough? Windows 11 Macro to toggle strikethrough? Office 2016
Novice
Macro to toggle strikethrough?
 
Join Date: Nov 2019
Posts: 22
NitroPress is on a distinguished road
Default

Quote:
Originally Posted by Logit View Post
Code:
CTRL / 5

...oh.


Quite a few 'experts' have failed to have that answer on tap. Thanks!
Reply With Quote
  #4  
Old 03-18-2024, 12:47 PM
NitroPress NitroPress is offline Macro to toggle strikethrough? Windows 11 Macro to toggle strikethrough? Office 2016
Novice
Macro to toggle strikethrough?
 
Join Date: Nov 2019
Posts: 22
NitroPress is on a distinguished road
Default

I would be interested in the VBA code for this, so that I can integrate it in macros. Thx.
Reply With Quote
  #5  
Old 03-18-2024, 02:17 PM
p45cal's Avatar
p45cal p45cal is offline Macro to toggle strikethrough? Windows 10 Macro to toggle strikethrough? Office 2021
Expert
 
Join Date: Apr 2014
Posts: 871
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

A whole cell:
Code:
Range("A1").Font.Strikethrough = True
Part of the text of a cell:
Code:
Range("A1").Characters(Start:=3, Length:=4).Font.Strikethrough = True
In both cases, if the range is multicelled, contiguous or not, all the cells will be affected.

To toggle:
Code:
Range("A1").Font.Strikethrough = Not Range("A1").Font.Strikethrough
Reply With Quote
  #6  
Old 03-18-2024, 04:40 PM
NitroPress NitroPress is offline Macro to toggle strikethrough? Windows 11 Macro to toggle strikethrough? Office 2016
Novice
Macro to toggle strikethrough?
 
Join Date: Nov 2019
Posts: 22
NitroPress is on a distinguished road
Default

Thanks.


Code:
 ActiveCell.Font.Strikethrough = Not ActiveCell.Font.Strikethrough
...works perfectly for my needs. Just one of those niggling little things that I've been trying to streamline for a while and couldn't figure out Excel's demands. Or ask the right question, apparently.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Toggle on & off Allow in-cell editing -or- a macro to do this Covert Codger Outlook 7 03-05-2024 02:44 PM
Macro for zooming toggle dovel Word 2 07-31-2020 02:32 PM
Macro to toggle strikethrough? Superscript directly above strikethrough bowlfreak_not Word 1 07-04-2018 03:36 PM
Macro to toggle strikethrough? Macro to toggle outline level Jennifer Murphy Word VBA 3 01-22-2014 11:22 PM
Macro to toggle outline level Jennifer Murphy Word VBA 0 07-08-2013 08:20 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:06 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft