- 1
- 0
- 约6.79千字
- 约 11页
- 2019-08-09 发布于广东
- 举报
VBA单元格操作详解
In cells, the insertion formula should use the cell,s formula property, and in some cases formla can be omitted, for example:
Sub insertion formula ()
Range (〃D4〃), 〃?Formla〃二〃二d3-d2〃, range (〃D4〃)二〃二d3-d2〃 can also be realized
End Sub
You can also extract formulas using the formla attribute, for example
Sub gets the cell formula ()
Msgbox the formula for cell E4 is: range (〃E4〃),. Formla, zzvbinformation^, get the formula?
End Sub
When you edit VBA, insert the cell formula so that you can insert the excel built-in formula.? Such as min, Max, sum and so on, formulas are OK
Sub selects all cells ()
Cells.select
End Sub
Sub selects all cells ()
Rows? select
End Sub
Sub selects all cells ()
Columns. select
End Sub
There are many ways to represent a cel1. For example, to represent a cell, BIO can be used:
Cells (10,2)
[blO]
Range (〃B10〃)
Cells 仃0, b)
Cells (〃B〃 10)
Cells (9* column number +2), such as 2003 column number of 256 columns, then the BIO is represented by cells (2036)
To explicitly represent cells, such as referencing cells from different worksheets in the same workbook, they are represented as
Worksheets (table name)?Range (cell address)
To refer to a cell with different work sheets, it is represented as
Workbooks (Workbook name),?Sheets (worksheet name),?Range (cell address)
But when you select a cell, if you want to select the cell of the non select worksheet, for example:
Sub selects the cell of the inactive worksheet ()
Worksheets (SHEET2),. Range (〃A10〃),. Select
End Sub
An error will occur? The correct method of expression is
Sub selects the cell of the inactive worksheet ()
Worksheets (〃SHEET2〃). Select
Range (〃A10〃). Select
End Sub
Selected region
Sub select region () Range (a3:b6), 〃?Select, range (“A3, 〃B6〃), 〃?Select, ,zrange,/ (cells (1, 3), cells (2, 6)), 〃? Select,
,z [a3:b6]? select, 〃a3:b6〃,both represent the selection region
End Sub
Sub selects a row ()
Range (〃6:6〃),? Select, rows (6)? Select
End Sub
Sub selects multiple rows
原创力文档

文档评论(0)