PDA

View Full Version : Set "1000 separator" in values imported from excel to PPT with VBA



Dborj
05-21-2010, 09:34 AM
:hi:

I import a number from an excel spreadsheet to a powerpoint textbox with an excel macro using an array.

Sample code :
PPPres.Slides(3).Shapes(ij).TextFrame.TextRange.Text = Round(VntArray(i,j) / 1000, 0)

However, it lacks a "1000 separator". For instance I would like to have that kind of format on PPT : "1 337" and I get "1337".

Is there an easy way to get it in a smooth "1000 separator" format ?

Thanks a lot for any insight !

Damien

Cosmo
05-21-2010, 01:31 PM
Look at the "FormatNumber" function:

Dim formattedNumber as string
Dim numberToFormat as double

numberToFormat = Round(VntArray(i,j) / 1000, 0)

formattedNumber = formatNumber(Expression:=numberToFormat ,GroupDigits:=vbTrue,numdigitsafterdecimal:= -1)


PPPres.Slides(3).Shapes(ij).TextFrame.TextRange.Text = formattedNumber