Chart data table format

Caliche

Active Member
Joined
Mar 26, 2002
Messages
339
I wanted to record a macro for giving format to a chart's data table. The generated code with the macro recorder was:

ActiveSheet.ChartObjects("Gráfico 3").Activate
"Tabla de datos".Comment.Shape.Select ' Here there is a mistake
Selection.AutoScaleFont = True
With Selection.Font
.Name = "Arial Narrow"
.FontStyle = "Normal"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With

but the second generated statement has an error (the statement appears red colored).

Could you tell me please why is this error generated?

Which ones are the VBA statements for formatting a chart's data table (change fornt type,size, etcetera.) ? . Currently using Excel XP.

Thanks a lot for your help.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Strange.
This was really how the recorder recorded it??? :eek:

Try:
<pre> <SPAN style="color:#00007F">With</SPAN> ActiveSheet.ChartObjects("Gráfico 3").Chart.DataTable.Font
.Name = "Arial Narrow"
.Size = 10
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN></pre>

Martin
 
Upvote 0
MartinK said:
Strange.
This was really how the recorder recorded it??? :eek:

Yes, Martin : that was as the recorder recorded it. It loks very strange to me, too. I did two things:

Created a new chart and run your macro: It worked perfectly.

In the same chart, I recorded a new macro:
- Selected the data table
- changed font type, size, etc. and I got the same error.

Does it depend of the way you select the data table? why does it record something related to comment.Shape and selects it instead of ActiveSheet.ChartObjects("Gráfico 3").Chart.DataTable ?.

May be a charts'guru could answer my doubt. Anyway, thanks a lot for your time.
 
Upvote 0
Hello again,

the macro recorder records usually in a very ineffective way, mainly, it uses selections. But the code should at least compile and contain no syntax errors.

You need to select only in very rare cases, e.g. when copying-pasting data between applications.

The comment object is a result of Range.Comment property. I really don't have clue as to how could chart object contain comments.


You're welcome
:biggrin:
Martin
 
Upvote 0

Forum statistics

Threads
1,214,905
Messages
6,122,175
Members
449,071
Latest member
cdnMech

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