Hi Forum,
I'm currently trying to write a macro to create a graph in Worksheet "GRAPH". The Data for this Graph in located in the Worksheet "HIST". This is the code i've written so far. Problem is it stops with a runtime error in the line i marked in bold. Any Ideas why this is happening?
Sub Macro2()
Dim ISIN As String
Dim REIHE, SPALTE As Integer
'get ISIN
ISIN = ActiveCell.Value
'find correct row
Sheets("HIST").Select
Range("A1").Select
Cells.Find(What:=ISIN, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
REIHE = ActiveCell.Row
With ActiveSheet
SPALTE = .Cells(REIHE, .Columns.Count).End(xlToLeft).Column
End With
Range(Cells(REIHE, 4), Cells(REIHE, SPALTE)).Name = "GraphSpreadRange"
Range(Cells(2, 4), Cells(2, SPALTE)).Name = "GraphTimeRange"
'build graph
Charts.Add
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
ActiveChart.SetSourceData Source:=Sheets("HIST").Range(GraphSpreadRange), PlotBy _
:=xlRows
ActiveChart.SeriesCollection(1).XValues = Sheets("HIST").Range(GraphTimeRange)
ActiveChart.SeriesCollection(1).Name = Sheets("HIST").Range("A" & REIHE)
ActiveChart.Location Where:=xlLocationAsObject, Name:="GRAPH"
With ActiveChart
.HasTitle = False
.HasLegend = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
End With
End Sub
Bookmarks