Tuesday, January 24, 2012

Excel VBA command (1)

Cell and Range
  1. Cells.Select -> select all cells in worksheet
  2. Range("A1").Select, Cells(1,1).Select -> select cell A1
  3. Range("A1").Value, Cells(1,1).Value -> return value of cell A1
  4. Rows(1).EntireRow.Select -> select entire row number 1
  5. Columns("A:B").EntireColumn.Select -> select entire column A and B
  6. Selection.CurrentRegion.Select -> select current cell region
  7. ActiveCell.Row, ActiveCell.Column -> return row or column number of active cell
  8. Selection.Rows.Count, Selection.Columns.Count -> return quantity of row or column of selected area
  9. Selection.CurrentRegion.Rows.Count, Selection.CurrentRegion.Columns.Count -> return quantity of row or column of current cell region
  10. Range("A1").Formula = "=B1+B2" -> create a formula =B1+B2 in cell A1
  11. Range("A1").FormulaR1C1 = "=RC[1]+R[1]C[1]" -> create a formula = B1+B2 in cell A1

No comments:

Post a Comment