V
vrk1
Hi,
I have a macro that splits the cells that have Hard returns inside all the
tables in my current document into separate rows. Someone sent me this macro
below to perform this function.
If I need this macro to operate only on the current Cell where my cursor is
and not all the tables in my document, how should I modify this?
Macro Below:
Sub RowSplit()
For x = 1 To ThisDocument.Tables.Count
For Each r In ThisDocument.Tables(x).Rows
If InStr(1, r, Chr(13)) < Len(r.Cells(1).Range) Then
rowsArray = Split(r.Cells(1).Range, Chr(13))
nSubRowCount = UBound(rowsArray)
If nSubRowCount > 1 Then
r.Select
For i = nSubRowCount To 1 Step -1
If Len(Replace(rowsArray(i), Chr(7), "")) > 0 Then
Selection.InsertRowsBelow
ThisDocument.Tables(x).Cell(r.Index + 1,
1).Range = rowsArray(i)
r.Select
End If
Next
Selection.Range = rowsArray(0)
End If
End If
Next
Next
End Sub
I have a macro that splits the cells that have Hard returns inside all the
tables in my current document into separate rows. Someone sent me this macro
below to perform this function.
If I need this macro to operate only on the current Cell where my cursor is
and not all the tables in my document, how should I modify this?
Macro Below:
Sub RowSplit()
For x = 1 To ThisDocument.Tables.Count
For Each r In ThisDocument.Tables(x).Rows
If InStr(1, r, Chr(13)) < Len(r.Cells(1).Range) Then
rowsArray = Split(r.Cells(1).Range, Chr(13))
nSubRowCount = UBound(rowsArray)
If nSubRowCount > 1 Then
r.Select
For i = nSubRowCount To 1 Step -1
If Len(Replace(rowsArray(i), Chr(7), "")) > 0 Then
Selection.InsertRowsBelow
ThisDocument.Tables(x).Cell(r.Index + 1,
1).Range = rowsArray(i)
r.Select
End If
Next
Selection.Range = rowsArray(0)
End If
End If
Next
Next
End Sub