View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] alvis@mail.act.edu is offline
external usenet poster
 
Posts: 2
Default updating data location to build a VBA graph

hello,

I am trying to build this simple macro where i can hit a keystroke and
graph whatever cells i have selected. The problem is that the macro
only graphs only from a fixed range and i want to be able to graph any
data i select.

here is the macro:

Sub graph()
'
' graph Macro
'
'
' Keyboard Shortcut: Ctrl+Shift+G
'
Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("C5:K5"),
PlotBy:= _
xlRows
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
ActiveChart.PlotArea.Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlNone
End With
With Selection.Interior
.ColorIndex = 15
.PatternColorIndex = 1
.Pattern = xlSolid
End With
With Selection.Border
.Weight = xlHairline
.LineStyle = xlNone
End With
Selection.Interior.ColorIndex = xlNone
ActiveChart.ChartArea.Select
With Selection.Border
.Weight = 2
.LineStyle = 0
End With
Selection.Interior.ColorIndex = xlAutomatic
Sheets("Sheet1").DrawingObjects("Chart 1").RoundedCorners = False
Sheets("Sheet1").DrawingObjects("Chart 1").Shadow = False
ActiveChart.PlotArea.Select
With Selection.Border
.Weight = xlThin
.LineStyle = xlAutomatic
End With
Selection.Interior.ColorIndex = xlNone
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(1).Select
With Selection.Border
.ColorIndex = 57
.Weight = xlThick
.LineStyle = xlContinuous
End With
With Selection
.MarkerBackgroundColorIndex = xlNone
.MarkerForegroundColorIndex = xlNone
.MarkerStyle = xlNone
.Smooth = False
.MarkerSize = 3
.Shadow = False
End With
ActiveChart.ChartArea.Select
ActiveChart.Legend.Select
Selection.Delete
End Sub


so graphs only data from C5:K5 and i want to be able to graph any data
i select...
thanks,
alvis