A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

vb macro format is wrong



 
 
Thread Tools Display Modes
  #1  
Old February 22nd, 2010, 08:45 PM posted to microsoft.public.excel.newusers
what which is up
external usenet poster
 
Posts: 1
Default vb macro format is wrong

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?

  #2  
Old February 23rd, 2010, 08:22 PM posted to microsoft.public.excel.newusers
JLatham
external usenet poster
 
Posts: 1,896
Default vb macro format is wrong

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"



"what which is up" wrote:

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?

  #3  
Old February 23rd, 2010, 08:25 PM posted to microsoft.public.excel.newusers
JLatham
external usenet poster
 
Posts: 1,896
Default vb macro format is wrong

Interesting tidbit shows up with a search for VarUserMemId:
http://stackoverflow.com/questions/9...6-source-files


"what which is up" wrote:

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?

  #4  
Old February 23rd, 2010, 08:31 PM posted to microsoft.public.excel.newusers
Dave Peterson
external usenet poster
 
Posts: 19,791
Default vb macro format is wrong

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.

what which is up wrote:

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?


--

Dave Peterson
  #5  
Old February 23rd, 2010, 09:49 PM posted to microsoft.public.excel.newusers
JLatham
external usenet poster
 
Posts: 1,896
Default vb macro format is wrong

Good lord! Sure makes me glad I installed 2010 in a separate virtual machine!

"Dave Peterson" wrote:

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.

what which is up wrote:

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?


--

Dave Peterson
.

  #6  
Old February 23rd, 2010, 10:25 PM posted to microsoft.public.excel.newusers
Dave Peterson
external usenet poster
 
Posts: 19,791
Default vb macro format is wrong

Or at least didn't install it on a production pc!

JLatham wrote:

Good lord! Sure makes me glad I installed 2010 in a separate virtual machine!

"Dave Peterson" wrote:

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.

what which is up wrote:

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?


--

Dave Peterson
.


--

Dave Peterson
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:39 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.