![]() |
|
#1
|
|||
|
|||
|
I have the problem with ms word table. How to merge empty cells before "ok" with a for loop and then replace empty cell with text “waiting list”, sample :
#before : empty empty ok empty empty empty ok empty ok #After : waiting list ok waiting list ok waiting list ok code : Sub try() Dim i As Integer, x As Integer, k As Integer x = ActiveDocument.Tables(1).Rows.Count 'k = empty cell count before "ok" For i = 1 To x - 1 With ActiveDocument.Tables(1) If .Cell(i + 1, 1).Range.Text = Chr(13) & Chr(7) Then .Cell(Row:=i, Column:=1).Merge MergeTo:=.Cell(Row:=i + k, Column:=1) End If End With Next i For i = 1 To x - 1 With ActiveDocument.Tables(1) If .Cell(i, 1).Range.Text = Chr(13) & Chr(7) Then .Cell(i, 1).Range.Text = “waiting list” End If End With Next i End Sub thanks |
|
#2
|
|||
|
|||
|
If the table is a single column table as your example indicates then something like this:
Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oCell As Cell
With ActiveDocument.Tables(1)
Set oCell = .Cell(1, 1)
Do
If oCell.RowIndex = .Rows.Count Then Exit Do
Do While Len(oCell.Range.Text) = 2 And Len(oCell.Next.Range.Text) = 2
If oCell.RowIndex = .Rows.Count Then Exit Do
oCell.Merge oCell.Next
Loop
If oCell.RowIndex = .Rows.Count Then Exit Do
Set oCell = oCell.Next
Loop
End With
lbl_Exit:
Exit Sub
End Sub
|
|
#3
|
|||
|
|||
|
it works, thanks sir
|
|
#4
|
|||
|
|||
|
thanks, it works
![]() one more, if i want to merge this https://www.msofficeforums.com/attac...1&d=1567962151 Last edited by Iput; 09-08-2019 at 06:09 PM. |
|
#5
|
|||
|
|||
|
Your link is invalid and won't open
|
|
#6
|
|||
|
|||
|
thanks, it works
![]() one more, if i want to merge this with loop Last edited by Iput; 09-08-2019 at 08:34 PM. |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Mail Merge Using Rules "IF" to add additional Text Based On Merge Field Content
|
Alfred | Mail Merge | 2 | 05-23-2017 10:59 PM |
| In Excel 2007-After Selecting Visibe Cells-How do I "Copy to Visible cells" Only | mag | Excel | 0 | 10-28-2012 08:04 PM |
| 'Linking' entered information to other "cells" from an original "cell" in MS Word | Wade | Word | 6 | 09-03-2012 05:22 PM |
Is the a way to delete the "empty" paragraphs?
|
Jamal NUMAN | Word | 3 | 07-27-2011 04:19 AM |
How to choose a "List" for certain "Heading" from "Modify" tool?
|
Jamal NUMAN | Word | 2 | 07-03-2011 03:11 AM |