Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.charting
|
|||
|
|||
![]()
hmm. It's really one way or the other not both.
If you add a chartobject directly to the worksheet then you don't need to change it's location. Also you don't need the Activechart reference when using the With chtob.Chart Sub Macro7() ' ' Macro7 Macro ' Macro recorded 23/02/2007 by School of Chemistry ' ' Keyboard Shortcut: Ctrl+j ' Dim chtob As ChartObject Set chtob = ActiveSheet.ChartObjects.Add(100, 100, 500, 400) ' where Left, etc., are coordinates in points With chtob.Chart .ChartType = xlXYScatterSmoothNoMarkers .HasTitle = False .Axes(xlCategory, xlPrimary).HasTitle = True .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "time / s" .Axes(xlValue, xlPrimary).HasTitle = True .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "current / A" With .Axes(xlCategory) .HasMajorGridlines = False .HasMinorGridlines = False End With With .Axes(xlValue) .HasMajorGridlines = False .HasMinorGridlines = False End With .HasLegend = False .PlotArea.ClearFormats .Axes(xlValue).AxisTitle.Select Selection.AutoScaleFont = True With Selection.Font .Name = "Arial" .FontStyle = "Regular" .Size = 12 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic .Background = xlAutomatic End With .Axes(xlCategory).AxisTitle.Select Selection.AutoScaleFont = True With Selection.Font .Name = "Arial" .FontStyle = "Regular" .Size = 12 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic .Background = xlAutomatic End With End With Range("A1").Select End Sub Dr Dan wrote: I've tried to add what you both suggested was ideal, but I'm getting and 'expected End With' error... see below What have I done wrong? Cheers Chaps, Dan Sub Macro7() ' ' Macro7 Macro ' Macro recorded 23/02/2007 by School of Chemistry ' ' Keyboard Shortcut: Ctrl+j ' Dim chtob As ChartObject Set chtob = ActiveSheet.ChartObjects.Add(100, 100, 500, 400) ' where Left, etc., are coordinates in points With chtob.Chart With Charts.Add .ChartType = xlXYScatterSmoothNoMarkers With ActiveChart .HasTitle = False .Axes(xlCategory, xlPrimary).HasTitle = True .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "time / s" .Axes(xlValue, xlPrimary).HasTitle = True .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "current / A" End With With ActiveChart.Axes(xlCategory) .HasMajorGridlines = False .HasMinorGridlines = False End With With ActiveChart.Axes(xlValue) .HasMajorGridlines = False .HasMinorGridlines = False End With ActiveChart.HasLegend = False ActiveChart.PlotArea.Select Selection.ClearFormats ActiveChart.Axes(xlValue).AxisTitle.Select Selection.AutoScaleFont = True With Selection.Font .Name = "Arial" .FontStyle = "Regular" .Size = 12 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic .Background = xlAutomatic End With ActiveChart.Axes(xlCategory).AxisTitle.Select Selection.AutoScaleFont = True With Selection.Font .Name = "Arial" .FontStyle = "Regular" .Size = 12 .Strikethrough = False .Superscript = False .Subscript = False .OutlineFont = False .Shadow = False .Underline = xlUnderlineStyleNone .ColorIndex = xlAutomatic .Background = xlAutomatic End With .Location Whe=xlLocationAsObject, Name:=rngAC.Parent.Name Range("A1").Select End Sub -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Indicate the location file on the work sheet | Excel Worksheet Functions | |||
UDF is updateing cells on another sheet with count from current sheet. | Excel Discussion (Misc queries) | |||
Track Mouse Location In a Sheet VBA | Excel Discussion (Misc queries) | |||
location of chart | Charts and Charting in Excel | |||
Can't save chart as object in current sheet | Charts and Charting in Excel |