Automating a data table for Actual/Forecast Chart

KansaiDorifto

New Member
Joined
Nov 16, 2021
Messages
9
Office Version
  1. 2010
Platform
  1. Windows
Hello all

I am trying to create a chart like below. Actual numbers as a solid line and forecast numbers as a dotted line.

1700708341153.png


I have used formulas to automate the table below that draws numbers:
1700708407511.png

My formula is "=IF(C$3="Actual", B30 / 1000, "")", trying to remove the blanks. But the chart ends up treating all blanks as zeros looking like below:

1700708517786.png


I can manually delete all zero values and the chart works, but I would like it automated. Is there a way to automatically tell excel to not show the zeros?

Thanks
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
HI
In your formula instead of double quotes put NON.DISP().
If I'm not mistaken in English it should be #N/A

HI,
Mario
 
Upvote 0
HI
In your formula instead of double quotes put NON.DISP().
If I'm not mistaken in English it should be #N/A

HI,
Mario
Thanks for the suggestion Mario. However it doesn't work as it changes the result to #Name?
 
Upvote 0
HI
Excuse me. I understood something else.
To do what you ask you need VBA. In the file I attach, try changing the date in the yellow cell and you will see that the graph adjusts.
Click on this link to get my work file.
Let me know. HI,
Mario
 
Upvote 0
HI
I humbly apologize for the forgetfulness.
This is the code to insert into the "Foglio1" module
VBA Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
  If Not Intersect(Target, Range("B1")) Is Nothing Then
  Dim vAddress As Range, i As Long, dt As Double, pt As Double
  dt = Cells(1, 2).Value
  ActiveSheet.ChartObjects(1).Activate
  With ActiveChart.SeriesCollection(1)
    Set vAddress = ActiveSheet.Range(Split(Split(.Formula, ",")(1), "!")(1))
    For i = 1 To vAddress.Cells.Count
      pt = Cells(3, i + 1)
      If pt > dt Then
        .Points(i).Format.Line.ForeColor.RGB = RGB(255, 0, 0)
        .Points(i).Format.Line.DashStyle = msoLineDashDotDot
      Else
        .Points(i).Format.Line.ForeColor.RGB = RGB(0, 0, 255)
        .Points(i).Format.Line.DashStyle = msoLineSingle
      End If
    Next i
  End With
  Cells(1, 1).Select
  End If
End Sub

Hio,
Mario
 
Upvote 0

Forum statistics

Threads
1,215,076
Messages
6,122,984
Members
449,092
Latest member
Mr Hughes

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
Back
Top