Clearing Cells - Miscellaneous Clearing Cells: To clear a...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Miscellaneous Clearing Cells: To clear a cell on excel, we need to tell VBA the exact location of the cell (sheet, row and column). Example: Sheet1.Cells(5, 2).ClearContents or Sheet1.Cells(5, 2).Clear As shown in the above example, there are two types of clear commands. The “ClearContents” command clears just the data (number or text) in the specified cell and leaves the formatting (font type, size, background color, etc.) intact. On the other hand, the “Clear” command clears everything (data and formatting) associated with that cell; in essence restores it to its default setting. Selecting Multiple Cells: VBA allows the programmer to select and operate on multiple cells simultaneously. To select multiple cells we need to use the “Range()” function and specify the starting cell and the ending cell of our selection. In the example shown to the right, the starting cell in the selection is Cell(3, 3) and the ending cell is Cell(10, 5). To select and clear this range using VBA, the syntax would be: When using R1C1: Sheet1.Range(Cells(3, 3), Cells(10, 5)).Clear When using A1: Sheet1.Range(“C3:E10”).Clear ...
View Full Document

This note was uploaded on 09/26/2011 for the course ENGR 1412 taught by Professor Staff during the Spring '08 term at Oklahoma State.

Ask a homework question - tutors are online