![]() |
|
![]() |
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]() How can I use Word Vba to insert a blank row after rows with cells containing certain texts? For example, I want to insert a blank row after a row that has the word "total" in a cell. There are several tables in the document and in each table there can be the word or the word criteria in a row at regular intervals. |
#2
|
||||
|
||||
![]()
Assuming no merged cells
Code:
Sub Macro1() Dim oTable As Table Dim oRow As Row Dim i As Integer, j As Integer For i = 1 To ActiveDocument.Tables.Count Set oTable = ActiveDocument.Tables(i) For j = oTable.Rows.Count To 1 Step -1 Set oRow = oTable.Rows(j) If InStr(1, oRow.Range, "total") > 0 Then oRow.Range.Rows.Add End If Next j Next i Set oTable = Nothing Set oRow = Nothing End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
![]()
Thank you, it worked perfectly, the problem is now solved.
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to combine the texts of all cells in a column without line break. | ericliu24 | Word VBA | 1 | 03-29-2022 05:28 PM |
![]() |
beginner | Excel Programming | 5 | 12-26-2014 12:29 AM |
![]() |
Shinaj | Excel Programming | 1 | 05-09-2014 09:17 AM |
![]() |
tinfanide | Word | 3 | 11-24-2013 06:37 AM |
![]() |
tareq | Excel | 12 | 09-29-2010 02:12 PM |