I have code that finds the columns of the earliest and latest dates for a Cashflow. I want to use these as part of a range specification for a Chart.
This is what I have so far;
What I need to do is change the refernce to H1:CM1 Etc. so that the ranges use the GraphStartCol and GraphFinishCol results.
Thank you for your help.
This is what I have so far;
Dim StartCol As Integer
Dim FinishCol As Integer
Dim MinDate As Long
Dim GraphStartCol As Integer
Dim MaxDate As Long
Dim GraphFinishCol As Integer
Dim AllStartDates As Range
Dim AllFinishDates As Range
' Set up Graph
' Get Earliest Date
MinDate = Application.WorksheetFunction.Min(Range("AllStartDates"))
' Get Graph Start Column
GraphStartCol = (Application.Match(CLng(MinDate), Range("1:1"), 1)) - 2
' Get Latest Date
MaxDate = Application.WorksheetFunction.Max(Range("AllFinishDates"))
' Get Graph Finish Column
GraphFinishCol = (Application.Match(CLng(MaxDate), Range("1:1"), 1)) + 2
'MsgBox (GraphStartCol & " " & GraphFinishCol)
' Set Graph Data
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.PlotArea.Select
ActiveChart.SetSourceData Source:=Sheets("Cashflow").Range("A1,H1:CM1,A25:A26,H25:CM26")
What I need to do is change the refernce to H1:CM1 Etc. so that the ranges use the GraphStartCol and GraphFinishCol results.
Thank you for your help.