Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
CLamar
 
Posts: n/a
Default Help!!! Trying to make a plot

I am trying to write a macro to create a plot in Excel. However the range of
the plot is different and it cant be hardcoded. Can anyone help with this.
The code i am using now is below, but it is given me error 1004. Where the
"**" are is where the error occurs


Private Sub VRH1H4Chartss()
'Option Explicit

Dim LastCellVRH1H4x As Long
Dim LastCellVRH1H4y As Long

On Error Resume Next
Application.DisplayAlerts = False
Charts("VRH1H4").Delete
On Error GoTo 0

With Sheets("SerialTable")
LastCellVRH1H4x = .Cells(.Rows.Count, "F").End(xlUp).Row
LastCellVRH1H4y = .Cells(.Rows.Count, "K").End(xlUp).Row
End With

Application.ScreenUpdating = False
Charts.Add
ActiveChart.Name = "VRH1H4"
With ActiveChart
.SeriesCollection.NewSeries
.SeriesCollection(1).XValues _
= Worksheets("SerialTable").Range("f2:F" & LastCellVRH1H4x) _
.Address(external:=True)
.SeriesCollection(1).Values _
= Worksheets("SerialTable").Range("k2:K" &
LastCellVRH1H4y).Value
.HasTitle = True
.ChartType = xlXYScatterSmooth
.HasLegend = False
.ApplyDataLabels Type:=xlDataLabelsShowValue
.Axes(xlCategory).TickLabels.Orientation = xlHorizontal
.ChartTitle.Font.Bold = True
.ChartTitle.Font.Size = 12
'.PlotArea.Top = 18
'.PlotArea.Height = 162
'.Axes(xlValue).MaximumScale = 0.6
'.Deselect
End With
Application.ScreenUpdating = True
Sheets("Program").Activate
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
Don Guillett
 
Posts: n/a
Default Help!!! Trying to make a plot

why not create your chart and then change to use a defined name instead
on the sheet where you need the nameeditnamesdefinename as desiredin
the refers to box
=offset($f$2,0,0,counta($f:$f)-1,1)
now this will autochange. Then in the series
=yourworkbookname.xls!namedrangename

--
Don Guillett
SalesAid Software

"CLamar" wrote in message
...
I am trying to write a macro to create a plot in Excel. However the range
of
the plot is different and it cant be hardcoded. Can anyone help with
this.
The code i am using now is below, but it is given me error 1004. Where
the
"**" are is where the error occurs


Private Sub VRH1H4Chartss()
'Option Explicit

Dim LastCellVRH1H4x As Long
Dim LastCellVRH1H4y As Long

On Error Resume Next
Application.DisplayAlerts = False
Charts("VRH1H4").Delete
On Error GoTo 0

With Sheets("SerialTable")
LastCellVRH1H4x = .Cells(.Rows.Count, "F").End(xlUp).Row
LastCellVRH1H4y = .Cells(.Rows.Count, "K").End(xlUp).Row
End With

Application.ScreenUpdating = False
Charts.Add
ActiveChart.Name = "VRH1H4"
With ActiveChart
.SeriesCollection.NewSeries
.SeriesCollection(1).XValues _
= Worksheets("SerialTable").Range("f2:F" & LastCellVRH1H4x) _
.Address(external:=True)
.SeriesCollection(1).Values _
= Worksheets("SerialTable").Range("k2:K" &
LastCellVRH1H4y).Value
.HasTitle = True
.ChartType = xlXYScatterSmooth
.HasLegend = False
.ApplyDataLabels Type:=xlDataLabelsShowValue
.Axes(xlCategory).TickLabels.Orientation = xlHorizontal
.ChartTitle.Font.Bold = True
.ChartTitle.Font.Size = 12
'.PlotArea.Top = 18
'.PlotArea.Height = 162
'.Axes(xlValue).MaximumScale = 0.6
'.Deselect
End With
Application.ScreenUpdating = True
Sheets("Program").Activate
End Sub



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
xy scatter chart-How can you make the axis equal for a 1H:1V plot mark Charts and Charting in Excel 9 May 23rd 06 01:26 AM
excel should make it easier to have a 1 to 1 plot area in chart Andy Charts and Charting in Excel 2 September 2nd 05 03:42 AM
Contour plot ojv Charts and Charting in Excel 2 January 10th 05 03:17 PM
make hidden window or workbook visible without specify the name mango Excel Worksheet Functions 1 December 30th 04 03:05 PM
make cell contents equal to null value - not blank, but empty mpierre Excel Worksheet Functions 1 December 29th 04 06:57 AM


All times are GMT +1. The time now is 12:17 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"