Start today with "Blue Fantasy" video learning VBA
The macro is actually the operation step
Recorded macros are automatically generated by VBA
In VB, you can write your own
You can specify a macro by using the form button
1. VBA Objects
' 1, workbooks
' Workbooks represents the workbook collection, all workbooks, Workbooks (n), which represents the nth workbook that has been opened
' Workbooks ("Workbook name")
' ActiveWorkbook the workbook that is being manipulated
The workbook where the ' ThisWorkBook ' code resides
' 2, worksheets
' Sheets ("sheet name")
' Sheet1 represents the first inserted sheet, Sheet2 represents the second inserted sheet ....
' Sheets (n) indicates the order, nth sheet
' ActiveSheet represents the active sheet, the worksheet on which the cursor is located
' Worksheet also represents worksheets, but does not include chart sheets, macro worksheets, and so on.
' 3, cell
' Cells all cells
' Range ("cell address")
' Cells (number of rows, number of columns)
' Activecell the cell being selected or edited
' Selection the cell or range of cells that is being selected or selected
2. VBA Properties
' VBA properties are features of VBA objects
' means that a property of an object is represented by the
Object.Properties= property value
Sub TTT ()
Range ("A1"). Value = 100
End Sub
Sub TTT1 ()
Sheets (1). Name = "Worksheet renamed"
End Sub
Sub Ttt2 ()
Sheets ("Sheet2"). Range ("A1"). Value = "ABCD"
End Sub
Sub Ttt3 ()
Range ("A2"). Interior.ColorIndex = 3
End Sub
3. VBA Method
' VBA method is an action that acts on a VBA object
' means that you can use a method for VBA objects in the following format:
' object. Method parameter Name: = parameter value
Sub Ttt4 ()
Steak. Degree of cooked: = Seven mature
Range ("A1"). Copy Range ("A2")
End Sub
Sub Ttt5 ()
Sheet1.move before:=sheets ("Sheet3")
End Sub
Macro Program statement: Complete a function after running
/////////////////////////////////////////////////////////
Sub function name ()
EXECUTE statement
End Sub
Sub Test ()
Range ("a1") = 100
End Sub
////////////////////////////////////////////////////////
Second, function program statement: Can return a value after running
/////////////////////////////////////////////////////////
Function Shcount ()
Shcount = Sheets.count
End Function
////////////////////////////////////////////////////////
Iii. statements that run in a program
/////////////////////////////////////////////////////////
Sub test2 ()
Call Test
End Sub
////////////////////////////////////////////////////////
20160122: Start learning VBA: (i), Macro and vba/(ii), VBA statement object method Properties