VBA Statement Object method Properties
' VBA object ' object in VBA is actually what we do with methods, properties in Excel supported by objects ' several common object representations in Excel ' 1, workbooks ' Workbooks represents a workbook collection, all workbooks, Workbooks (n), which represents the nth workbook that has been opened ' Workbooks (workbook name) ' ActiveWorkbook Workbook in action ' ThisWorkBook ' code in the workbook ' 2, worksheet ' ' Sheets ("sheet name") ' Sheet1 represents the first inserted worksheet, Sheet2 represents the second inserted sheet .... ' Sheets (n) represents in sorted order, nth worksheet ' activesheet represents the active sheet, the worksheet where the cursor is located ' worksheet also represents a worksheet, 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 cells being selected or edited ' Selection The cell or range of cells that is being selected or selected
VBA Methods and properties: ' VBA Properties ' VBA properties are features of VBA objects ' means of representing properties of an object are ' object. Property = 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 &Nbsp; end sub ' two VBA methods ' VBA methods are actions that Act on VBA objects ' means that a method is used for VBA objects, which can be: in the following format   SUB TTT4 () steak. Degree of cooked: = Seven mature range ("A1"). Copy range ("A2") end sub sub ttt5 () sheet1.move before:=sheets ("Sheet3") end sub
' The basic structure of code in VBA and Components ' VBA statement ' one, macro program statement ' can be completed after a function Sub test () ' Start Statement Range ("a1") = 100End Sub ' Concluding sentence ' Two, function program statement ' can be returned after running A value function Shcount () Shcount = Sheets.count End Function ' III, statement applied in the program Sub test2 () call Test End Sub Sub Test3 () for x = 1 "For next" loop statement Cells (x, 1) = x Next x End Sub
This article is from the "Newcode" blog, make sure to keep this source http://newcode.blog.51cto.com/4190167/1878714
(a) Macros and VBA