![]() |
|||
|
Moving around the Worksheet in VBA for ExcelRows and Columns in VBA for ExcelColumns and ColumnTo select a single column you will write: To select a set of contiguous columns you will write: A special use of Range Column (no "s") will be used in a line of code like the following: See Part 4 to learn about Activecell and Selection and see Part 5 on how to use this property with a variable Rows and RowTo select a single row you will write: Notice than Rows is plural even if you are selecting only one row. To select a set of contiguous rows you will write: A special use of Range Row (no "s") will be used in a line of code like the following: See Part 4 to learn about Activecell and Selection and see Part 5 on how to use this property with a variable EntireColumn, EntireRowYou can also select the column or the row with this: If more than one cell is selected the following code will select all rows and columns covered by the selection: InsertHere is the code to insert rows. The number of rows inserted depends on the number of rows that are selected when executing the "Insert" command. If only on row is selected only one row is inserted if 3 rows are selected 3 rows are added. Notice below that the words Rows and Columns are plural. Inserting one row: Inserting 3 rows: Inserting one column: Inserting 3 columns: Hidden Rows("1").Hidden=True Remember that when you go down a column cell by cell with Selection.Offset(1,0).Select the hidden cells gets also selected. So if you are in cell A12 and cell A13 is hidden from A12 you are going down to A13 even if it is hidden and not to the next visible cell A14. Learn More |