View Single Post
 
Old 12-04-2014, 02:22 AM
PRA007's Avatar
PRA007 PRA007 is offline Windows 7 32bit Office 2010 32bit
Competent Performer
 
Join Date: Dec 2014
Location: Ahmedabad, Gujrat, India
Posts: 145
PRA007 is on a distinguished road
Default How to find number of coma and then add that number of rows in word using macro?

I have this table





What I have done is recorde macro and it look like this.


Selection.MoveRight Unit:=wdCell
Selection.EndKey Unit:=wdLine
Selection.TypeText Text:="@"
Selection.MoveRight Unit:=wdCell
Selection.Copy
Selection.MoveLeft Unit:=wdCell
Selection.ConvertToTable Separator:=wdSeparateByCommas, NumColumns:=1, _
NumRows:=9, AutoFitBehavior:=wdAutoFitFixed
With Selection.Tables(1)
.Style = "Table Grid"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
End With
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Cut
Selection.MoveLeft Unit:=wdCell
Selection.EndKey Unit:=wdLine
Selection.TypeParagraph
Selection.PasteAndFormat (wdFormatPlainText)
Selection.TypeBackspace
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.InsertRowsBelow 1
Selection.MoveUp Unit:=wdLine, Count:=29
Selection.PasteAndFormat (wdTableOverwriteCells)
Selection.MoveRight Unit:=wdCell
Selection.MoveDown Unit:=wdLine, Count:=29
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell


My question is is there a short method to count the comma separated number of entries and then add that number of new row and then paste the data accordingly.
what I currently do is add some 3O row and then paste the data using paste special merge the entry and then removing the empty row using macro.
Reply With Quote