Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can any one help me out in rescaling the Chart using VBA (Visual Basic
Editor) in excel ? Thanks and Regards, Peri |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Turn on the macro recorder and see what you get for methods and properties.
After editing the code to replace "ActiveChart" with a variable (for easier debugging later), you should have something like the following. I also added a quick error handler in case the currently active sheet is a worksheet instead of a chart. Sub RescaleChart() Dim crtMyChart As Chart On Error GoTo ErrRescaleChart Set crtMyChart = ActiveWorkbook.Sheets("MyChart") With crtMyChart.Axes(xlValue) .MinimumScale = 10 .MaximumScale = 20 End With With crtMyChart.Axes(xlCategory) .MinimumScale = 1 .MaximumScale = 5 End With Exit Sub ErrRescaleChart: MsgBox "Sheet is not a chart.", vbCritical + vbOKOnly End Sub Replace the constants with appropriate values, or functions that return a value based on the data. You might also want to pass in an object variable for the workbook and the chart as arguments, instead of developing them like I did in the above example. -- Regards, Bill "Peri" wrote in message ... Can any one help me out in rescaling the Chart using VBA (Visual Basic Editor) in excel ? Thanks and Regards, Peri |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Turn on the macro recorder and see what you get for methods and properties.
After editing the code to replace "ActiveChart" with a variable (for easier debugging later), you should have something like the following. I also added a quick error handler in case the currently active sheet is a worksheet instead of a chart. Sub RescaleChart() Dim crtMyChart As Chart On Error GoTo ErrRescaleChart Set crtMyChart = ActiveWorkbook.Sheets("MyChart") With crtMyChart.Axes(xlValue) .MinimumScale = 10 .MaximumScale = 20 End With With crtMyChart.Axes(xlCategory) .MinimumScale = 1 .MaximumScale = 5 End With Exit Sub ErrRescaleChart: MsgBox "Sheet is not a chart.", vbCritical + vbOKOnly End Sub Replace the constants with appropriate values, or functions that return a value based on the data. You might also want to pass in an object variable for the workbook and the chart as arguments, instead of developing them like I did in the above example. -- Regards, Bill "Peri" wrote in message ... Can any one help me out in rescaling the Chart using VBA (Visual Basic Editor) in excel ? Thanks and Regards, Peri |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Using the chat | Excel Discussion (Misc queries) | |||
Chat | Excel Discussion (Misc queries) | |||
การดึง Excel ลงมาใช้ใน chat ทำโดยวิธีไหนไดเบ้างครับ ช่วยบอกผมทีนะค | Charts and Charting in Excel | |||
How to draw chat by entering equation | Charts and Charting in Excel | |||
Chat Room | New Users to Excel |