VBA for Dynamic Chart Data with N/A or Dynamic Range

jenitak87

New Member
Joined
Aug 25, 2021
Messages
2
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi All,

I can define columns and data for required columns and So on for dynamin range
But how do i convert it into complex charts in the excel file under Tab "Chart Data"
Can anyone advise

Sub create_graph()

Dim ws As Excel.Worksheet
Dim x As Range
Dim y As Range

Set ws = ActiveWorkbook.Worksheets("Chart Data")

Set x = ws.Range("B8:B" & ws.Cells(ws.Rows.Count, "B").End(xlUp).Row)
Set y = ws.Range("C8:B" & ws.Cells(ws.Rows.Count, "C").End(xlUp).Row)

ws.Shapes.AddChart.Select
With ActiveChart
.ChartType = xlLine
.SeriesCollection.NewSeries
.SeriesCollection(1).Values = x
End With

End Sub

Now there are 2 questions here
  • Can i create a chart where i can ignore blanks and N/A so my data can alight better in Chart
  • Can you help me to with additional code to create the image chart - This option is better for me
 

Attachments

  • Chart 1.PNG
    Chart 1.PNG
    167.2 KB · Views: 12
  • Capture 1.PNG
    Capture 1.PNG
    149 KB · Views: 13

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
A reminder:

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at:

If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,224,737
Messages
6,180,653
Members
452,992
Latest member
TokugawaIesuma

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