fredlo2010
12-25-2011, 02:17 PM
Hello, I am trying to write this macro for work that will take a report from my Company's operating program and give a little more Commercial appealing look. This is something I have to do several times a day and it is kind of a tedious task.
I have modified several parts of the document and I am very happy with the results. I am trying to get a piece of code to search for a text string and then split the table right above it. I managed to put together a code but I need to add the exception of if row selected is the first row then search next. I get the code looping for ever in the first text string it finds.
This is the code:
Sub Macro1()
'
' Macro1 Macro
'
'
Dim sText As String
Dim bmRange As Range
sText = "Total amount"
Selection.Find.ClearFormatting
With Selection.Find
.Text = sText
.Wrap = wdFindContinue
Do While Selection.Find.Execute
If Selection.Information(wdWithInTable) Then
Selection.Rows.Select
Selection.SplitTable
End If
Loop
End With
End Sub
Thanks in advance
I have modified several parts of the document and I am very happy with the results. I am trying to get a piece of code to search for a text string and then split the table right above it. I managed to put together a code but I need to add the exception of if row selected is the first row then search next. I get the code looping for ever in the first text string it finds.
This is the code:
Sub Macro1()
'
' Macro1 Macro
'
'
Dim sText As String
Dim bmRange As Range
sText = "Total amount"
Selection.Find.ClearFormatting
With Selection.Find
.Text = sText
.Wrap = wdFindContinue
Do While Selection.Find.Execute
If Selection.Information(wdWithInTable) Then
Selection.Rows.Select
Selection.SplitTable
End If
Loop
End With
End Sub
Thanks in advance