Missing code in macro

  • Thread starter Thread starter Lee
  • Start date Start date
L

Lee

I recorded a macro but when I go into the editor a lot of the code is
missing. All I see are objects that are activated or selected (see below).
I am using Excel 2007 on WindowsXP. Does anyone know what is going on? I
never had this problem with Excel 2003.
Thanks in advance,
Lee

Sub Macro2()
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.Legend.Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.ChartTitle.Select
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveSheet.ChartObjects("Chart 1").Activate
End Sub
 
You probably already know that there are some things that the recorder will
not record. It basically records cell/range selections and keystrokes.
 
I just recorded this with 2003 to test.

Sub Macro6()
'
' Macro6 Macro
' Macro recorded 12/16/2008 by Donald B. Guillett
'

'
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartArea.Select
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "mytitlehere"
End With
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlLeft
ActiveWindow.Visible = False
Windows("20081201.xls").Activate
Range("U26").Select
End Sub

I then went to 2007 and recorded this. As you can see, I also had problems
but it seems to work. I haven't worked much with charts in 2007. I'm sure it
can be cleaned up without selections.

Sub Macro7() '2007 recordes

ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.ChartTitle.Select

ActiveChart.ChartTitle.Text = "xxxNewtitlehere"
ActiveSheet.ChartObjects("Chart 2").Activate

ActiveChart.Legend.Select
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.Legend.LegendEntries(1).Select
ActiveSheet.ChartObjects("Chart 2").Activate

Range("S18").Select
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.Legend.Select
ActiveSheet.ChartObjects("Chart 2").Activate
Selection.Top = 95.1
Selection.Height = 33.354
ActiveSheet.ChartObjects("Chart 2").Activate
Selection.Left = 15.058
Selection.Top = 92.1
Range("V15").Select
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top