Code to insert a coma
hi Howard,
Sub ConIt()
Dim i As Integer, y As Integer, a As String
y = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column - 4
For i = 1 To y
If IsNumeric(Range("D1").Offset(0, i)) And i < y Then a = "'" Else a
= ""
Range("D1").Value = Range("D1").Value & " " & Range("D1").Offset(0,
i) & a
Next
End Sub
isabelle
Le 2013-01-12 23:40, Howard a écrit :
I run a macro and it puts these values in cells D1 to N1.
This can be longer or shorter but the format stays the same for the
single letters & numbers following the word in D1 ("Abit" here).
Abit A 9 B 8 C 7 D 6 E 5
Then thecode below is called and I get this ALL IN ONE CELL, D1.
Abit A 9 B 8 C 7 D 6 E 5
Sub ConIt()
Dim i As Integer
i = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column - 3
For i = 1 To i
Range("D1").Value = Range("D1").Value & " " & Range("D1").Offset(0, i)
Next
End Sub
How can I make the code put a coma after each number EXCEPT the last number which is 5 here.
Thanks,
Howard
|