Delete row in Word in VBA

mrpman97

Board Regular
Joined
Apr 11, 2007
Messages
56
I am using a find to select the letters""SCV"
I then want to delete the entire row
The code below only deletes SVC. How can I delete the entire row (line)?

Dim count As Integer
count = 0

Selection.HomeKey unit:=wdStory
With Selection.Find
.ClearFormatting
.Text = "SVC"
.Wrap = wdFindContinue


.Execute
Do While .Found = True


count = count + 1

MsgBox count

'Selection.Delete unit:=wdCharacter, count:=1
'Selection.MoveRight


'Selection.MoveDown unit:=wdParagraph, count:=1

Selection.Delete

.Execute
Loop
End With
End Sub
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Try changing this...
Code:
Selection.Delete unit:=wdCharacter, count:=1
...to this
Code:
Selection.Delete unit:=wdLine, count:=1

Denis
 
Upvote 0
Hi mrpman97,

Actually, you can do it without a macro, using a wildcard Find/replace, where:
Find = [!^13]@SCV[!^13]{1,}^13
Replace = nothing
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,543
Members
452,924
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top