Directory
ActiveCell
ActiveWorkbook
AdvancedFilter
AutoFill
ActiveCell
1. Check whether the active cell exists
Sub activeCell()
If ActiveCell Is Nothing Then End If
End Sub
2. Set the active cell by specifying an offset
Sub offset()
ActiveCell.Offset(RowOffset:=-2, ColumnOffset:=4).Activate
End Sub
The first parameter of the offset function is the offset of the row, the second parameter is the offset of column (which can be unspecified), and the value can be given directly when used, such as offset (2, 4). The value is less than 0 offset in the opposite direction. Offset (). Activate with offset (). The select is equivalent in effect.
3. Set the current value of the active cell
Sub SetValue
ActiveCell.Value = "Hello World!"
End Sub
4. Set the formula for the currently active cell
Sub fomula()
ActiveCell.Formula = "=SUM($G$12:$G$22)"
End Sub
To assign a formula's expression directly to the Formula property, the formula expression can refer to the Formula menu in Excel, such as summing, counting, averaging, and so on.
5. Get the address of the currently active cell
Sub selectRange()
MsgBox ActiveCell.Address
End Sub
The format of the address, such as: $A $11.