|
-
Jan 22nd, 2004, 01:48 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Search and delete issues
Okay, now I have a good one.
I need to do the following
run through a spreadsheet looking for an instance of criteria, i.e.,
Name Place This criteria can be part of a larger value in the same cell i.e., Name Place Day Month zip, etc....
Then after it is found I need to delete all rows below it until I reach a cell that is formated BOLD. then I need to stop the delete process and do the search process again.
__________________
Swoozie
Swoozie
Somedays you just should not get out of bed.
-
Jan 22nd, 2004, 03:54 PM
#2
Junior Member
Hey there,
OK, this should get you started.
Sub DeleteLinesWacky()
'
Dim blnFound As Boolean
Dim strText As String 'This is the text you are looking for
Dim intLastRow As Integer 'This keeps a record of the last row you found your bold text in
Dim intFoundRow As Integer 'This is the row under the row you find your string
'
strText = "Josh"
'
intLastRow = 1
blnFound = True
Do Until blnFound = False
On Error Resume Next
Range(intLastRow & ":65536").Find(What:=strText).Activate
If blnFound = True Then
ActiveCell.Offset(1, 0).Select
intFoundRow = ActiveCell.Row
Do Until ActiveCell.Font.Bold = True Or ActiveCell.Row = 65536
ActiveCell.Offset(1, 0).Select
Loop
If ActiveCell.Row = 65536 Then Exit Sub
intLastRow = ActiveCell.Row - 1
If intFoundRow < intLastRow Then
Range(intFoundRow & ":" & intLastRow).Select
Selection.Delete
End If
Range("A" & intFoundRow).Select
intLastRow = ActiveCell.Row
End If
Loop
End Sub
Last edited by Yesuslave; Jan 22nd, 2004 at 04:44 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|