Name for excel graph problem with the vba generator

0 votes

So I'm attempting to create a graph chart using a name as a range of data. I generated a code using Excel, and I got the following:

Sub Macro_name_graph2()
'
' Macro_name_graph2 Macro
'

'
    ActiveChart.SeriesCollection.NewSeries
    ActiveChart.FullSeriesCollection(1).name = "=""data1_1"""
    ActiveChart.FullSeriesCollection(1).Values = "==test_macro.xlsm!data1_1ord"
    ActiveChart.FullSeriesCollection(1).XValues = "==test_macro.xlsm!data1_1abs"
End Sub

what I put in the actual chart was ='test_macro.xlsm'!data1_1ord and ='test_macro.xlsm'!data1_1abs

But not when I try to run it again, I have an error 1004 at

 ActiveChart.FullSeriesCollection(1).Values = "==test_macro.xlsm!data1_1ord"

So I tried to put 

ActiveChart.FullSeriesCollection(1).Values = "=='test_macro.xlsm'!data1_1ord" 

And it didn't work. Can someone please help me with this?

Jan 7 in Others by Kithuzzz
• 27,740 points
45 views

1 answer to this question.

0 votes

Change the name of the workbook :

Sub Macro_name_graph2()
   With ActiveChart.SeriesCollection.NewSeries
        .Name = "=Book1!data1_1"
        .Values = "=Book1!data1_1ord"
        .XValues = "=Book1!data1_1abs"
    End With
End Sub
answered Jan 7 by narikkadan
• 51,240 points

Related Questions In Others

0 votes
1 answer

I want to compare two Excel files and highlight the differences with VBA

The workbook doesn't have the UsedRange property ...READ MORE

answered Jan 13 in Others by narikkadan
• 51,240 points
43 views
0 votes
1 answer

VBA copy data from other file - problem with file name change

To look for the source file, use ...READ MORE

answered Jan 20 in Others by narikkadan
• 51,240 points
33 views
0 votes
1 answer

VBA Export as PDF and Save to Location with name as per a Cell in the worksheet

Following is the code that gets generated ...READ MORE

answered Jan 20 in Others by narikkadan
• 51,240 points
40 views
0 votes
1 answer
0 votes
1 answer

How to modify Powerpoint Chart ChartData by Excel VBA

Example: Code: Set pptApp = GetObject(, "PowerPoint.Application") Set pptPres = ...READ MORE

answered Oct 16, 2022 in Others by narikkadan
• 51,240 points
397 views
0 votes
0 answers

xcel VBA Chart counting and formatting

I want to develop a macro that ...READ MORE

Oct 31, 2022 in Others by Kithuzzz
• 27,740 points
52 views
0 votes
1 answer

Automating production of graphs using VBA

You have to change: chrtname = Cells(i, 2).Value To: chrtname ...READ MORE

answered Jan 23 in Others by narikkadan
• 51,240 points
35 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
522 views
0 votes
1 answer

How to get the excel file name / path in VBA

Use FullName, for example: strFileFullName = ThisWorkbook.FullName ...READ MORE

answered Dec 23, 2022 in Others by narikkadan
• 51,240 points
60 views
0 votes
1 answer

How to increment the Range of a For Each loop - Excel VBA

Your formula seems to sum 1 single ...READ MORE

answered Jan 7 in Others by narikkadan
• 51,240 points
58 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP