Excel 2007 | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | TBU/EVE/234 | |||||
2 | TBU/EVE/111 | |||||
3 | TBU/EVE/222 | |||||
4 | EVE/TBU/1000 | |||||
5 | ||||||
Sheet1 |
Excel 2007 | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | TBU/EVE/234 | TBU/EVE/235 | TBU/EVE/236 | TBU/EVE/237 | ||
2 | TBU/EVE/111 | TBU/EVE/112 | TBU/EVE/113 | TBU/EVE/114 | ||
3 | TBU/EVE/222 | TBU/EVE/223 | TBU/EVE/224 | TBU/EVE/225 | ||
4 | EVE/TBU/1000 | EVE/TBU/1001 | EVE/TBU/1002 | EVE/TBU/1003 | ||
5 | ||||||
Sheet1 |
Option Explicit
Sub CalculateStrings()
' hiker95, 09/18/2013
' http://www.mrexcel.com/forum/excel-questions/727229-calculation-strings.html#post3578407
Dim c As Range, s, d As Long
Application.ScreenUpdating = False
For Each c In Range("A1", Range("A" & Rows.Count).End(xlUp))
s = Split(c, "/")
For d = 1 To 3 Step 1
c.Offset(, d) = s(0) & "/" & s(1) & "/" & s(2) + d
Next d
Next c
Columns.AutoFit
Application.ScreenUpdating = True
End Sub
kwebihaf,
Sample raw data:
Excel 2007
A B C D 1 TBU/EVE/234 2 TBU/EVE/111 3 TBU/EVE/222 4 EVE/TBU/1000 5
<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>Sheet1
After the macro:
Excel 2007
A B C D 1 TBU/EVE/234 TBU/EVE/235 TBU/EVE/236 TBU/EVE/237 2 TBU/EVE/111 TBU/EVE/112 TBU/EVE/113 TBU/EVE/114 3 TBU/EVE/222 TBU/EVE/223 TBU/EVE/224 TBU/EVE/225 4 EVE/TBU/1000 EVE/TBU/1001 EVE/TBU/1002 EVE/TBU/1003 5
<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>Sheet1
Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).
1. Copy the below code
2. Open your NEW workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.
Code:Option Explicit Sub CalculateStrings() ' hiker95, 09/18/2013 ' http://www.mrexcel.com/forum/excel-questions/727229-calculation-strings.html#post3578407 Dim c As Range, s, d As Long Application.ScreenUpdating = False For Each c In Range("A1", Range("A" & Rows.Count).End(xlUp)) s = Split(c, "/") For d = 1 To 3 Step 1 c.Offset(, d) = s(0) & "/" & s(1) & "/" & s(2) + d Next d Next c Columns.AutoFit Application.ScreenUpdating = True End Sub
Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm
Then run the CalculateStrings macro.
But is there any Excel function/formula that i can use rather than the Macro code?
Assuming your data starts in cell A2, this formula placed in B1 and copied down to the last row with data, and then all those cells copied across to the last column you want to fill, seems to work...Exactly that is how I wanted the results to be.
But is there any Excel function/formula that i can use rather than the Macro code?
Hi FredThanks Rick.
That formula helps and has worked.
Another thing, what if I want the results down the columns, say from Cell B1 to Cell B100.
How do I go about it?
Regards,
FRED
Excel 2010 | ||||||
---|---|---|---|---|---|---|
A | B | C | D | |||
1 | TBU/EVE/234 | TBU/EVE/111 | TBU/EVE/222 | EVE/TBU/1000 | ||
2 | TBU/EVE/235 | TBU/EVE/112 | TBU/EVE/223 | EVE/TBU/1001 | ||
3 | TBU/EVE/236 | TBU/EVE/113 | TBU/EVE/224 | EVE/TBU/1002 | ||
4 | TBU/EVE/237 | TBU/EVE/114 | TBU/EVE/225 | EVE/TBU/1003 | ||
5 | TBU/EVE/238 | TBU/EVE/115 | TBU/EVE/226 | EVE/TBU/1004 | ||
Sheet2 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
A2 | =SUBSTITUTE(A1,LOOKUP(10^308,--RIGHT(A1,{1;2;3;4;5;6})),"")&LOOKUP(10^308,--RIGHT(A1,{1;2;3;4;5;6}))+1 |
Worksheet Formulas
Cell Formula A2 =SUBSTITUTE(A1,LOOKUP(10^308,--RIGHT(A1,{1;2;3;4;5;6})),"")&LOOKUP(10^308,--RIGHT(A1,{1;2;3;4;5;6}))+1
<thead>
</thead><tbody>
</tbody>
<tbody>
</tbody>