Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Changing decimal place of y-axis in chart with vba


I have a macro that creates charts for alot of people. I cant seem t
figure out how to change the decimal placing of the y-axis in vba
Right now it is at 2 decimal places (which is the default) and I don
want it to show any decimal places, just the whole number. Does anyon
kow the code that will allow me to do this? The code for my macro i
below. Any help would be appreciated.

Thanks
Jonathan


Sub Chart()



Dim i As Long
Dim n As Long
Dim wsh As Worksheet
Dim cho As ChartObject
Dim cht As Chart
Set wsh = Worksheets("Emp Data")
n = wsh.Range("A65536").End(xlUp).Row
For i = 2 To n
Set cho = wsh.ChartObjects.Add(Top:=160 * i - 310, Left:=10, _
Height:=150, Width:=300)
Set cht = cho.Chart
cht.ChartType = xlColumnClustered
cht.SeriesCollection.Add Source:=wsh.Range("F" & i)
cht.SeriesCollection.Add Source:=wsh.Range("N" & i)
cht.SeriesCollection.Add Source:=wsh.Range("P" & i)
cht.SeriesCollection(1).Name = "taint"
cht.SeriesCollection(2).Name = "4%"
cht.SeriesCollection(3).Name = "bump it"
cht.HasAxis(xlCategory) = False
cht.ApplyDataLabels (xlDataLabelsShowValue)

Next i
End Su

--
jtr999
-----------------------------------------------------------------------
jtr9999's Profile: http://www.excelforum.com/member.php...fo&userid=3749
View this thread: http://www.excelforum.com/showthread.php?threadid=57151

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default Changing decimal place of y-axis in chart with vba

The macro record is useful for generating the base syntax for a problem
like this.

cht.Axes(xlValue).TickLabels.NumberFormat = "0"

Cheers
Andy

jtr9999 wrote:
I have a macro that creates charts for alot of people. I cant seem to
figure out how to change the decimal placing of the y-axis in vba.
Right now it is at 2 decimal places (which is the default) and I dont
want it to show any decimal places, just the whole number. Does anyone
kow the code that will allow me to do this? The code for my macro is
below. Any help would be appreciated.

Thanks
Jonathan


Sub Chart()



Dim i As Long
Dim n As Long
Dim wsh As Worksheet
Dim cho As ChartObject
Dim cht As Chart
Set wsh = Worksheets("Emp Data")
n = wsh.Range("A65536").End(xlUp).Row
For i = 2 To n
Set cho = wsh.ChartObjects.Add(Top:=160 * i - 310, Left:=10, _
Height:=150, Width:=300)
Set cht = cho.Chart
cht.ChartType = xlColumnClustered
cht.SeriesCollection.Add Source:=wsh.Range("F" & i)
cht.SeriesCollection.Add Source:=wsh.Range("N" & i)
cht.SeriesCollection.Add Source:=wsh.Range("P" & i)
cht.SeriesCollection(1).Name = "taint"
cht.SeriesCollection(2).Name = "4%"
cht.SeriesCollection(3).Name = "bump it"
cht.HasAxis(xlCategory) = False
cht.ApplyDataLabels (xlDataLabelsShowValue)

Next i
End Sub



--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Subtracting two 2-decimal place numbers gives result 13-decimal places? [email protected] Excel Worksheet Functions 5 March 12th 07 10:38 PM
How to place a secondary y axis bar in a bar chart next to two primary y axis bars? Dmitry Excel Discussion (Misc queries) 3 May 4th 06 01:58 AM
How to place a secondary y axis bar in a bar chart next to two primary y axis bars? Dmitry Charts and Charting in Excel 2 May 4th 06 01:58 AM
Converting 2-place decimal value to floating point decimal number with leading zero Kermit Piper Excel Discussion (Misc queries) 3 March 18th 06 06:20 PM
changing to two place decimal Debbie Excel Worksheet Functions 1 February 5th 06 04:53 AM


All times are GMT +1. The time now is 10:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"