rurounisena
New Member
- Joined
- Apr 13, 2018
- Messages
- 7
Sub BO_ID_Prep()
Dim rng As Range
Dim i As String
For Each rng In Selection
i = i & rng & ";"
Next rng
ActiveCell.Offset(1, 1).Value = Trim(i)
ActiveCell.Offset(2, 1).Select
ActiveCell.FormulaR1C1 = "=LEFT(R[-1]C,LEN(R[-1]C)-1)"
Selection.Copy
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub
The above script takes all selected cells and puts their data into one cell separated by a ;
<tbody>
</tbody>
My issue is when the numbers have leading zeros they are dropped when being added.
<tbody>
</tbody>
Can someone please help me with this?
Dim rng As Range
Dim i As String
For Each rng In Selection
i = i & rng & ";"
Next rng
ActiveCell.Offset(1, 1).Value = Trim(i)
ActiveCell.Offset(2, 1).Select
ActiveCell.FormulaR1C1 = "=LEFT(R[-1]C,LEN(R[-1]C)-1)"
Selection.Copy
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub
The above script takes all selected cells and puts their data into one cell separated by a ;
2345 | 2345;3658;2499 |
36568 | |
2499 |
<tbody>
</tbody>
My issue is when the numbers have leading zeros they are dropped when being added.
0234 | what it does 234;35;2345 |
0035 | |
2345 | what I want 0234;0035;2345 |
<tbody>
</tbody>
Can someone please help me with this?