Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-08-2019, 08:53 AM
Iput Iput is offline How to merge empty cells before "ok" with a for loop Windows 10 How to merge empty cells before "ok" with a for loop Office 2007
Novice
How to merge empty cells before "ok" with a for loop
 
Join Date: Sep 2019
Posts: 4
Iput is on a distinguished road
Default How to merge empty cells before "ok" with a for loop

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
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to merge empty cells before "ok" with a for loop 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
How to merge empty cells before "ok" with a for loop Is the a way to delete the "empty" paragraphs? Jamal NUMAN Word 3 07-27-2011 04:19 AM
How to merge empty cells before "ok" with a for loop How to choose a "List" for certain "Heading" from "Modify" tool? Jamal NUMAN Word 2 07-03-2011 03:11 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:43 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft