View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
icq_giggles icq_giggles is offline
external usenet poster
 
Posts: 5
Default Find partial cell format

Thank you Dave - your post just showed on my pc.

LOL - I love both programs - they give me job security LOL.

I tried it and it removed some of the strikethrough text and placed the
strikethrough formatting on my regular text in the cell (that it kept). This
was only on the cells where the strikethrough text appeared first. Other
cells it worked great, and for my purposes (Access will strip the formatting)
this will probably work, but for other users I wanted to flag this issue.

Thank you so much for your help!
--
Thank you,
gig

"Dave Peterson" wrote:

What is this thing called Access? I thought that if the job had to be done, it
should be done in Excel <vbg.

Test this against a copy--or close without saving--just in case!

Option Explicit
Sub testme01()
Dim wks As Worksheet
Dim rng As Range
Dim myCell As Range
Dim myStrikeThrough As Variant 'true/false/null (for mixture)
Dim iCtr As Long
Dim myStr As String

Set wks = Worksheets("sheet1") '<- change as required

With wks
Set rng = Nothing
On Error Resume Next
Set rng = .Cells.SpecialCells(xlCellTypeConstants, xlTextValues)
On Error GoTo 0
End With

If rng Is Nothing Then
'no constants to check
Exit Sub
End If

For Each myCell In rng.Cells
myStrikeThrough = myCell.Font.Strikethrough
If myStrikeThrough = False Then
'do nothing
ElseIf myStrikeThrough = True Then
'get rid of all the characters
myCell.ClearContents
Else
myStr = ""
For iCtr = 1 To Len(myCell.Value)
If myCell.Characters(Start:=iCtr, Length:=1) _
.Font.Strikethrough = True Then
'do nothing
Else
myStr = myStr & Mid(myCell.Value, iCtr, 1)
End If
Next iCtr
myCell.Value = myStr
End If
Next myCell
End Sub

icq_giggles wrote:

Do you have sample code I could see? Played with VBA - working on expanding
my knowledge but mostly in Access.
--
Thank you,
gig

"Dave Peterson" wrote:

I think you'll have to loop through the cells in the range you want to fix.

Then loop through each character to find the character(s) to delete.



icq_giggles wrote:

I have cells that have part of the cell formatted with strikethrough font.
All of these also have text that is not strikedthrough. Is there a way to
find and delete the strikethrough text? The "Find" with the strikethrough
format selected doesn't work - I assume because of the mixed format. If I
tell it use selected cell formating - it selects the regular format and
therefore finds ALL the cells in the column.
--
Thank you,

--

Dave Peterson


--

Dave Peterson