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 ;
[TABLE="width: 500"]
<tbody>[TR]
[TD]2345[/TD]
[TD]2345;3658;2499[/TD]
[/TR]
[TR]
[TD]36568[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2499[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
My issue is when the numbers have leading zeros they are dropped when being added.
[TABLE="width: 500"]
<tbody>[TR]
[TD]0234[/TD]
[TD]what it does 234;35;2345[/TD]
[/TR]
[TR]
[TD]0035[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2345[/TD]
[TD]what I want 0234;0035;2345[/TD]
[/TR]
</tbody>[/TABLE]
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 ;
[TABLE="width: 500"]
<tbody>[TR]
[TD]2345[/TD]
[TD]2345;3658;2499[/TD]
[/TR]
[TR]
[TD]36568[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2499[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
My issue is when the numbers have leading zeros they are dropped when being added.
[TABLE="width: 500"]
<tbody>[TR]
[TD]0234[/TD]
[TD]what it does 234;35;2345[/TD]
[/TR]
[TR]
[TD]0035[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2345[/TD]
[TD]what I want 0234;0035;2345[/TD]
[/TR]
</tbody>[/TABLE]
Can someone please help me with this?