Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

More Excel Analysis

Status
Not open for further replies.

guitardave78

Programmer
Sep 5, 2001
1,294
GB
Thanks for the last bit of help!!! With some mods it works just like i want.
Next thing i spent all day doing is trying to make the macro write a chart dynamic ranges.
This is what i have

Charts.Add
ActiveChart.ChartType = xlLineMarkersStacked
ActiveChart.SetSourceData Source:=Sheets("Tasks").Range("A3:A12,H3:H12"), _
PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:="Chart"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Analysis for " & myFolder
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Subject"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Accuracy"
End With
With ActiveChart
.HasAxis(xlCategory, xlPrimary) = True
.HasAxis(xlValue, xlPrimary) = True
End With
ActiveChart.Axes(xlCategory, xlPrimary).CategoryType = xlCategoryScale
With ActiveChart.Axes(xlCategory)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
With ActiveChart.Axes(xlValue)
.HasMajorGridlines = False
.HasMinorGridlines = False
End With
ActiveChart.HasLegend = False
Sheets("Chart").Select


where you see Range "("A3:A12,H3:H12")"
I need the A12 and H12 to be dynamic depending on the number of rows.
Thanks in advance
 
Use the row numbers as variables:
Code:
Dim sRange As String
Dim iLastRow As Integer

sRange = "A3:A" & iLastRow & ",H3:H" & iLastRow

Range(sRange)
 
i'm getting application defined or object defined error??

Dim sRange As String
Dim iLastRow As Integer

sRange = "A3:A" & iLastRow & ",H3:H" & iLastRow


Charts.Add
ActiveChart.ChartType = xlLineMarkersStacked
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range(sRange), _
PlotBy:=xlColumns
 
You've gotta set iLastrow to something....How about a meld of the two suggestions:

Private Sub SelectRange()
Dim sRange As String
Dim iLastRow

ActiveSheet.Cells(3, 1).Select
Selection.End(xlDown).Select
iLastRow = Selection.Row
sRange = "A3:A" & iLastRow & ",H3:H" & iLastRow

Charts.Add
ActiveChart.ChartType = xlLineMarkersStacked
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range(sRange), _
PlotBy:=xlColumns ETC Tyrone Lumley
augerinn@gte.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top