View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.programming
Howard Howard is offline
external usenet poster
 
Posts: 536
Default Code to insert a coma

On Sunday, January 13, 2013 11:18:27 AM UTC-8, Claus Busch wrote:
Hi Howard,



Am Sun, 13 Jan 2013 13:41:34 +0100 schrieb Claus Busch:



For i = 5 To Cells(1, Columns.Count).End(xlToLeft).Column Step 2


[D1] = [D1] & " " & Cells(1, i) & " " & Cells(1, i + 1) & ", "


Next


[D1] = Left([D1], Len([D1]) - 2)




there are two space between the parts. Try:



Sub Test()

Dim i As Integer

Dim LCol As Integer



For i = 5 To Cells(1, Columns.Count).End(xlToLeft).Column Step 2

[D1] = [D1] & " " & Cells(1, i) & " " & Cells(1, i + 1) & ","

Next

[D1] = Left([D1], Len([D1]) - 1)

End Sub





Regards

Claus Busch

--

Win XP PRof SP2 / Vista Ultimate SP2

Office 2003 SP2 /2007 Ultimate SP2


I tried the -1 in place of the -2 and the only difference I could detect in the outcome was a coma at the very end of the string.

The two spaces are not a problem, I had not even noticed. I'll probably stay with the two spaces and no coma at the end.

I appreciate your diligence.

Regards,
Howard