Monday, July 5, 2010

VB and Excel (Mac, 2004)

Mac, Excel 2008, VB not supported
1. Tools->Macro->Visual Basic Editor
a) double click sheet1, copy following VB code:
------------------------------------
Sub proFirst()
Range("A1").Value = 34
Range("A2").Value = 66
Range("A3").Formula = "=A1+A2"
Range("A1").Select
End Sub
-------------------------------------
b) Recording Macro: Click Run-> Run Sub(F5)
In sheet 1, Column 1, 34,66 and 100 are shown

2. Tools->New Macro
In working sheet, type A1->100, B1->1000
A2->20, B2->15
stop recording macro
go to Visual basic editor,
Module->Module1, the following code can be seen
-------------------------------
Sub Macro1()
'
' Macro1 Macro
' Macro recorded by Jiansen Lu
'

'
ActiveCell.FormulaR1C1 = "100"
Range("B1").Select
ActiveCell.FormulaR1C1 = "1000"
Range("A2").Select
ActiveCell.FormulaR1C1 = "20"
Range("B2").Select
ActiveCell.FormulaR1C1 = "15"
End Sub
-----------------------------------------------

No comments:

Post a Comment