VBA

BaGRoS

New Member
Joined
Oct 25, 2022
Messages
34
Office Version
  1. 365
Platform
  1. Windows
Hi

I never used VBA for Excel before.

Why this command give error, second one also, but If I uncomment "On Error..." second one fill chart as should be.

image001.png


Sorry for picture, not source. I used this at work, now I'm at home...

Any advice?

Many thanks,

BaGRoS
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Chart code isn't my area of expertise but I'll guess it's because you don't activate the chart first.


Resume Next will cause errors to be ignored and code will just continue to run. It's not suitable for most cases and I'd say this ins one of those.
 
Upvote 0
I add .Activate

Code:
    With Sheets("Graph_Template")
    .Activate

but still have error on:

1667384850672.png


and

1667384888312.png


and

1667384938953.png


Even with the errors, everything seems to be working... It shows the error, and populates the table with the correct values...
Which is weird, but good for me :P

Many thanks,
BaGRoS
 
Upvote 0
You're activating a sheet, they activated a chart?
This example sets chart elements by using the various constant values to an active chart.
 
Upvote 0
Code:
Set objChrt = .ChartObjects("Chart 6")
        objChrt.Activate
        Set chrt = objChrt.Chart

The problem is only with the bottom chart:
1667401997758.png


and way if this
Code:
chrt.SetSourceData (Sheets(SheetName).Range(StartVal_X & ":" & EndVal_X))
gives me an error, it still fills in this chart??!!
 
Upvote 0
I don't know enough about this to offer an explanation. Sorry, best I could do is point you to the link after doing some research.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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