Show dates on chart vba

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
969
I'm using the below to graph data. How can I include the dates on the graph?


VBA Code:
Sub PLineChart()
Dim MyChart As Chart
Dim FName As String
Dim LRow As Long, Rng As Range, i As Long

With Application
    .ScreenUpdating = False
    .EnableEvents = False
    .Calculation = xlCalculationManual
End With

Set Wks = ActiveSheet
Set MyChart = Wks.Shapes.AddChart(xlLine).Chart
Set Rng = Range("A6", Range("A" & Rows.Count).End(xlUp)).Resize(, 18)

If Rng.Rows.Count > 1 Then
    Rng.AdvancedFilter xlFilterCopy, Range("T2:U3"), Range("BI6:BJ6"), Unique:=False
End If
LRow = Application.CountA(Range("BJ:BJ")) + 5

For i = 7 To LRow
    Range("BK" & i) = Format(Application.Sum(Range("BJ7:BJ" & i)), "$#,0.00")
Next

With MyChart
    .ChartArea.Height = 190
    .ChartArea.Width = 312
    .PlotVisibleOnly = False
    .SeriesCollection(1).Format.Line.Weight = 1
    .SetSourceData Source:=ActiveSheet.Range("BK7:BK" & LRow)
    If Application.Subtotal(2, ActiveSheet.Range("BK7:BK" & LRow)) = 1 Then
        .SeriesCollection(1).MarkerStyle = xlMarkerStyleCircle
    End If
    .Axes(xlCategory).MajorTickMark = xlNone
    .Axes(xlCategory).TickLabelPosition = xlNone
    .Axes(xlValue).TickLabels.NumberFormat = "$#,##0_);[Red]($#,##0)"
    .Legend.Delete
End With

FName = Environ("temp") & "\temp.gif"
MyChart.Export Filename:=FName, FilterName:="GIF"
frmData.iChart.Picture = LoadPicture(FName)
Wks.ChartObjects(1).Delete
Kill FName

With Wks
    .Range("T3:U3").Clear
    .Range("BI7:BK" & LRow).Clear
End With

With Application
    .Calculation = xlCalculationAutomatic
    .EnableEvents = True
    .ScreenUpdating = True
End With
End Sub

1593996879897.png
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Watch MrExcel Video

Forum statistics

Threads
1,129,373
Messages
5,635,884
Members
416,886
Latest member
coreyalaurence37

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top