![]() |
#4
|
||||
|
||||
![]()
It is certainly possible. Based on your example:
Code:
Sub Macro1() Dim oRow As Row Dim oRng As Range Dim iEnd As Integer, i As Integer Dim strEnd As String Dim strText As String, strText2 As String For Each oRow In Selection.Tables(1).Rows strText = "" Set oRng = oRow.Cells(1).Range oRng.End = oRng.End - 1 If InStr(1, oRng.Text, ">-<") > 0 Then strEnd = Split(oRng.Text, "-")(1) iEnd = NumberFromText(strEnd) For i = 1 To iEnd strText = strText & Replace(Split(oRng.Text, "-")(0), "1", i) If i < iEnd Then strText = strText & Chr(11) Next i oRng.Text = strText End If Next oRow End Sub Function NumberFromText(sText As String) As Integer Dim Length_of_String As Integer Dim iPos As Integer Dim strNum As String Length_of_String = Len(sText) For iPos = 1 To Length_of_String If (IsNumeric(Mid(sText, iPos, 1))) = True Then strNum = strNum & Mid(sText, iPos, 1) End If Next iPos If Len(strNum) = 0 Then NumberFromText = 0 Else NumberFromText = CInt(strNum) End If End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
ganesang | Word VBA | 50 | 08-29-2018 12:53 AM |
![]() |
Ricardo Sousa | Excel | 6 | 06-09-2018 10:51 PM |
![]() |
GemBox | Word | 6 | 03-12-2018 05:24 AM |
Macro to Expand Outline Heading in Outline View? | Clueless in Seattle | Word VBA | 1 | 05-04-2015 05:44 PM |
![]() |
redzan | Word VBA | 3 | 05-22-2014 04:22 PM |