PDA

View Full Version : [SOLVED:] Adding Numbers & Move Content To New Line



Jasa P
11-23-2013, 10:17 AM
Hi, thank you for passing by in my thread :)
I have current issue about adding numbers (01, 02, 03, 04, 05, so on..)
after specific characters & move the next content to new line by using a macro.

For example:
A01=2324.3545.2356.5657.2137.6466x4.4.6/3425.3455x3.6.6/132x2.3/4544.31234.4565x4/45.435.56.3/456x3.3

A02=54.45.55.34x4/456.565.676x3/4564.3453.5775.2342x4.5.6/5646.2342.7324.5466.3242x10.20.15/12.23.45.67x5

C05=123.4543.5765.12.67.234x10/2324.4565.4564.1233x5/2423.2344.4563x3.5.5/2342.3435.5675.2342.2424.6577x3.10.12

B52=32.44.23.34x10/456.565.676x3/4564.3453.5775.2342x4.5.6/5646.2342.7324.5466.3242x10.20.15/12.23.45.67x5/4236.3453.5775.2342x4.5.6
and so on...

The result would be:
A01=01(ENTER)
(TAB)2324.3545.2356.5657.2137.6466x4.4.6/3425.3455x3.6.6/132x2.3/4544.31234.4565x4/45.435.56.3/456x3.3

A02=02(ENTER)
(TAB)54.45.55.34x4/456.565.676x3/4564.3453.5775.2342x4.5.6/5646.2342.7324.5466.3242x10.20.15/12.23.45.67x5

C05=03(ENTER)
(TAB)123.4543.5765.12.67.234x10/2324.4565.4564.1233x5/2423.2344.4563x3.5.5/2342.3435.5675.2342.2424.6577x3.10.12

B321=04(ENTER)
(TAB)32.44.23.34x10/456.565.676x3/4564.3453.5775.2342x4.5.6/5646.2342.7324.5466.3242x10.20.15/12.23.45.67x5/4236.3453.5775.2342x4.5.6
and so on...


Summary: (x) is multiplication and dot (.) is sum

10.20.30x10/ --> the result is 30
235.458.101x25.20/ --> the result is 135
1120.1135x10/ --> the result is 20

So, numbers before (x) is counted by the sum of dot (.)+1 -->(first result)
Number/s after (x) is counted by the sum of numbers between (x) and slash (/) -->(second result)
The final result is multiplication of first and second result

There are 3 ways for possible numbers before (x)
2 numbers/+dot(.), ex: 01 or 45 etc
3 numbers/+dot(.), ex: 245 or 939 etc
4 numbers/+dot(.), ex: 1174 or 8364 etc

Possible sum after (x)
For 2 numbers before (x) --> 1 sum
For 3 numbers before (x) --> 1 or 2 sum
For 4 numbers before (x) --> 1 or 2 or 3 sum


Thank you in advance :)
Regards,
Jasa

macropod
11-24-2013, 12:38 AM
Try a macro like:

Sub Demo()
Application.ScreenUpdating = False
Dim i As Long
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "[!^13=]@="
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = True
.Execute
End With
Do While .Find.Found
i = i + 1
.InsertAfter Format(i, "00") & vbCr & vbTab
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Application.ScreenUpdating = True
MsgBox i & " records updated."
End Sub

Jasa P
11-24-2013, 08:52 AM
Hi Paul, thank you so much for helping me again :)
It really works :) Thank you :)