vb macro format is wrong

W

what which is up

I am using Excel 2007. I have a question. I recorded a macro which enters in
A1 the value 1
B1 the value 2
C1 the value 3

the code looks like this.
Sub Macro2()
+OnAction <= VB_VarUserMemId1VB_VarUserMemId
Range& VB_VarUserMemIdB1VB_VarUserMemId '+AxisGroup
+OnAction <= VB_VarUserMemId2VB_VarUserMemId
Range& VB_VarUserMemIdC1VB_VarUserMemId '+AxisGroup
+OnAction <= VB_VarUserMemId3VB_VarUserMemId
Range& VB_VarUserMemIdD1VB_VarUserMemId '+AxisGroup
End Sub

I thought it should be this kind of format--ish
ActiveCell.FormulaR1C1 = "1)"
Range("B1").Select
ActiveCell.FormulaR1C1 = "2"
Range("C1").Select

what the heck is +OnAction format?
 
J

JLatham

Looks kind of like you recorded the macro while dealing with some data
associated with a chart/graph?
Can't give you a definitive answer about the +OnAction as I haven't delved
into recording macros dealing with charts/graphs in 2007 since the early days
of its release when it could take 10 minutes just to change the color on a
graph line.

But you're right, a macro recorded while just changing values in B1:B3 ends
up looking like
Range("B1").Select
ActiveCell.FormulaR1C1 = "1"
Range("B2").Select
ActiveCell.FormulaR1C1 = "2"
Range("B3").Select
ActiveCell.FormulaR1C1 = "3"
Range("B4").Select

which could easily be made more compact as:
Range("B1").FormulaR1C1 = "1"
Range("B2").FormulaR1C1 = "2"
Range("B3").FormulaR1C1 = "3"
 
D

Dave Peterson

Did you install xl2010?

I've read some posts that say that this can mess up the recorded syntax. That
post mentioned xl2002, but maybe it (xl2010) breaks the recording in other
versions, too.
 

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

Top