|
Moving around the Worksheet in VBA for ExcelSelection, Activecell, CurrentRegion and other special addressesActiveCell The ActiveCell is the selected cell or the first cell of the range that you have selected. All the methods and properties that apply to Cells, Range, Rows or Columns also apply to Activecell and Selection Try this in Excel: The ActiveCell is a very important concept that you will need to remember as you start developing more complex procedures. Select and SelectionThe object Selection comprises what is selected. It can be a single cell, many cells, a column, a row, many of these, a chart, an image or any other object. All the methods and properties that apply to Cells, Range, Rows or Columns also apply to Activecell and Selection For example: CurrentRegionOne of the most important property when working with sets of data and databases: Cells is all the cells of a worksheet as CurrentRegion is all the cells of a database (from where it is to the first empty column on the right ad the first empty row at the bottom. To see what Excel recognizes as a database see the website on Excel EndHere is something that you will use at the beginning of your programming career but that you will stay away from once you have started working with variables: Range("A38").End(xlDown).Select will take you to the last cell with a value in column A Note: End will work if there are no empty cells within the row or the column. If there is only one line of data in your sheet and your code is: If there is only one column of data in your sheet and your code is: So learn rapidly about counting rows and columns and storing the number in a variable like "varNbRows" to use: Acting without Selecting From anywhere on the sheet you can write orders about other cells or ranges. For example you can write: But BEWARE. When moving down one cell after the operation with: Discover more tips |