Hi all,
Here's the problem. I have created a macro that will create some graphs, however, the filename and title have to be hard coded into the macro. I would like to have the macro use a variable, ie, name of file that is open, inside of the macro where you see "FILE NAME VARAIBLE GOES HERE". Below you will find part of the macro in question...
Any help would be greatly appreciated...
Regards
Jake
Sub SarData()
'
' SarData Macro
' Macro recorded 2/1/02 by Manpower User
'
' Keyboard Shortcut: Ctrl+Shift+S
'
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("FILE NAME VARIABLE GOES HERE"
.Range( _
"A1:E275"
, PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "FILENAME VARIABLE GOES HERE"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Time"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Percent Utilized"
End With
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScale = 100
.MinorUnit = 1
.MajorUnit = 10
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
End With
End Sub
Here's the problem. I have created a macro that will create some graphs, however, the filename and title have to be hard coded into the macro. I would like to have the macro use a variable, ie, name of file that is open, inside of the macro where you see "FILE NAME VARAIBLE GOES HERE". Below you will find part of the macro in question...
Any help would be greatly appreciated...
Regards
Jake
Sub SarData()
'
' SarData Macro
' Macro recorded 2/1/02 by Manpower User
'
' Keyboard Shortcut: Ctrl+Shift+S
'
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("FILE NAME VARIABLE GOES HERE"
"A1:E275"
ActiveChart.Location Where:=xlLocationAsNewSheet
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "FILENAME VARIABLE GOES HERE"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Time"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Percent Utilized"
End With
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScaleIsAuto = True
.MaximumScale = 100
.MinorUnit = 1
.MajorUnit = 10
.Crosses = xlAutomatic
.ReversePlotOrder = False
.ScaleType = xlLinear
End With
End Sub