PDA

View Full Version : Import data from excel to powerpoint(% not showing)



Jhon90
08-27-2021, 11:27 AM
Sir,
I need some help.
I want to import data from excel sheet which contains % ie 2%, 4%, .....( in column B)
but when import to powerpoint through vba it display as 0.02, 0.04 (not in 2% or 4%).
How it should display as 2% or 4%?


tbhm = GetObject(filepath).sheets(1).Range("B2:B6")
Application.Presentations(1).Slides(1).Shapes("Population").TextFrame.TextRange.Text = tbhm(6, 1)

arnelgp
08-28-2021, 01:40 AM
tbhm = GetObject(filepath).sheets(1).Range("B2:B6")
Application.Presentations(1).Slides(1).Shapes("Population").TextFrame.TextR ange.Text = FormatPercent(tbhm(6, 1))

Jhon90
08-28-2021, 05:59 AM
sir,
After using
Application.Presentations(1).Slides(1).Shapes("Population").TextFrame.TextR ange.Text = FormatPercent(tbhm(6, 1))

it display 2% as 2.00% (not as 2% which I want)

Is there any solution without changing below line but any changes in excel sheet may give the result I wanted ?

tbhm = GetObject(filepath).sheets(1).Range("B2:B6")
Application.Presentations(1).Slides(1).Shapes("Population").TextFrame.TextR ange.Text = tbhm(6, 1)

arnelgp
08-28-2021, 06:06 AM
you supply a 2nd parameter to the function. pass 0:

Application.Presentations(1).Slides(1).Shapes("Population").TextFrame.TextR ange.Text = FormatPercent(tbhm(6, 1), 0)

Jhon90
08-28-2021, 07:12 AM
Thanks its working now.

But is there any solution to change only in excel sheet ie in column/cell because in many case I import text/string so don't want edit in "tbhm(6, 1)".