Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Need to remove text with strikethrough - Excel 2007

I 'inherited' a large spreadsheet where every cell contains free form
text. A single cell can contain text with strikethroughs and plain
text (no strikethroughs). I need to create some VBA to delete only the
text with strikethroughs and leave the plain text within each cell.
I'm not worried about speed.
Does anyone have any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 896
Default Need to remove text with strikethrough - Excel 2007

try:

Sub znajdz()

On Error Resume Next

For Each Cell In Selection
counter = 0
For i = 1 To Len(Cell)
If Cell.Characters(Start:=i - counter,
Length:=1).Font.Strikethrough Then
Cell.Characters(Start:=i - counter, Length:=1).Delete
If Cell.Characters(Start:=i - counter, Length:=2) =
Chr(32) & Chr(32) Then
Cell.Characters(Start:=i - counter,
Length:=2).Delete
End If
counter = counter + 1
End If
Next i
Next Cell
End Sub

this will leave you with double spaces somewhere
you may get rid of them by using CTRL+H (Edit-Replace)

HIH
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,358
Default Need to remove text with strikethrough - Excel 2007

If this is just a 1 time thing, you don't need a macro, just select the
entire sheet, go to Format--Cells, the Font tab, the Strikethrough box
should be gray, showing some cells have it, some don't, click it twice, the
first time, the checkbox will still be checked but white (if left here, your
entire spreadsheet would have strikethrough), check it again, and it will
ensure all data on spreadsheet has no strikethrough.
--
John C


"HD" wrote:

I 'inherited' a large spreadsheet where every cell contains free form
text. A single cell can contain text with strikethroughs and plain
text (no strikethroughs). I need to create some VBA to delete only the
text with strikethroughs and leave the plain text within each cell.
I'm not worried about speed.
Does anyone have any ideas?

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,358
Default Need to remove text with strikethrough - Excel 2007

whooops!, nevermind, i just re-read your post :D
--
John C


"HD" wrote:

I 'inherited' a large spreadsheet where every cell contains free form
text. A single cell can contain text with strikethroughs and plain
text (no strikethroughs). I need to create some VBA to delete only the
text with strikethroughs and leave the plain text within each cell.
I'm not worried about speed.
Does anyone have any ideas?

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Need to remove text with strikethrough - Excel 2007

Give this a try...

Sub RemoveStrikeThruText()
Dim X As Long
Dim C As Range
For Each C In Selection
For X = Len(C.Value) To 1 Step -1
If C.Characters(X, 1).Font.Strikethrough Then
C.Characters(X, 1).Delete
End If
Next
C.Value = Application.WorksheetFunction.Trim(C.Value)
Next
End Sub

Note that it cleans up **all** multiple spaces in the text string, including
any that were there before it was run. If that is not acceptable, post back
and let us know.

Rick


"HD" wrote in message
...
I 'inherited' a large spreadsheet where every cell contains free form
text. A single cell can contain text with strikethroughs and plain
text (no strikethroughs). I need to create some VBA to delete only the
text with strikethroughs and leave the plain text within each cell.
I'm not worried about speed.
Does anyone have any ideas?




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Need to remove text with strikethrough - Excel 2007

On Jul 17, 4:53*am, Jarek Kujawa wrote:
try:

Sub znajdz()

On Error Resume Next

For Each Cell In Selection
counter = 0
* * For i = 1 To Len(Cell)
* * * * If Cell.Characters(Start:=i - counter,
Length:=1).Font.Strikethrough Then
* * * * * * Cell.Characters(Start:=i - counter, Length:=1).Delete
* * * * * * * * If Cell.Characters(Start:=i - counter, Length:=2) =
Chr(32) & Chr(32) Then
* * * * * * * * * * Cell.Characters(Start:=i - counter,
Length:=2).Delete
* * * * * * * * End If
* * * * * * counter = counter + 1
* * * * End If
* * Next i
Next Cell
End Sub

this will leave you with double spaces somewhere
you may get rid of them by using CTRL+H (Edit-Replace)

HIH


Wonderfully straightforward solution! Works great! Thanks!
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 896
Default Need to remove text with strikethrough - Excel 2007

thks but Rick's is better...
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do i remove a toolbar from excel 2007? Stefano[_2_] Excel Discussion (Misc queries) 8 July 16th 07 08:48 AM
How to remove the ' ^ etc. in Excel 2007? Laibeus Lord Setting up and Configuration of Excel 1 March 18th 07 06:05 PM
how do i remove a cell name in Excel 2007? kermit Excel Discussion (Misc queries) 2 March 8th 07 10:14 PM
How to remove red strikethrough generated as an error? FiscallyCOC Excel Discussion (Misc queries) 1 October 5th 05 06:56 PM
Strikethrough on Excel. How? Jerry Baritone Excel Worksheet Functions 1 January 3rd 05 09:55 PM


All times are GMT +1. The time now is 07:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"