Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I am fairly new at this and am tryi

Status
Not open for further replies.

pmsbony

IS-IT--Management
May 17, 2001
36
0
0
GB
I am fairly new at this and am trying to do the following.

1. select a range of text
2. delete any cells in that selection that contain text that has the strikethrough property as true.

I can do the second bit on a singl cell easily enough with

Sub Macro2()
If ActiveCell.Font.Strikethrough = True Then ActiveCell.ClearContents
End Sub

but I am stumped as to how to link it into a selection so that the macro looks at every cell selected and then removes anything that has been struck through.

i am sure I am missing somethin easy here, so any pointers will be helpful

pete
 
The syntax you want is like this:
Code:
Sub Macro2()
Dim c as Range
  For each c in ActiveSheet.UsedRange
    If c.Font.Strikethrough = True Then c.ClearContents
  next c
End Sub

 
One slight modification:

Zathras' method looks at all used cells on the sheet. To just look at the cells you have selected (as your post seems to indicate you want to do), change Zathras' code to read:
Code:
Sub Macro2()
Dim c as Range
  For each c in Selection
    If c.Font.Strikethrough = True Then c.ClearContents
  next c
End Sub
Hope this helps!
VBAjedi [swords]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top