| Start |
|---|
| Qualifying References When referring to a For example: Is not fully qualified: The The easiest way to correct this is to use a Alternatively, you can use a Worksheet variable. (This will most likely be preferred method if your code needs to reference multiple Worksheets, like copying data from one sheet to another.) Another frequent problem is referencing the Worksheets collection without qualifying the Workbook. For example: The worksheet However, avoid using the following: Similarly for Is the same as: |
| Deleting rows or columns in a loop If you want to delete rows (or columns) in a loop, you should always loop starting from the end of range and move back in every step. In case of using the code: You will miss some rows. For example, if the code deletes row 3, then row 4 becomes row 3. However, variable The right code would be |
| ActiveWorkbook vs. ThisWorkbook
The The |
| Single Document Interface Versus Multiple Document Interfaces Be aware that Microsoft Excel 2013 (and higher) uses Single Document Interface (SDI) and that Excel 2010 (And below) uses Multiple Document Interfaces (MDI). This implies that for Excel 2013 (SDI), each workbook in a single instance of Excel contains its own ribbon UI: Conversely for Excel 2010, each workbook in a single instance of Excel utilized a common ribbon UI (MDI):
This raise some important issues if you want to migrate a VBA code (2010 <->2013) that interact with the Ribbon. A procedure has to be created to update ribbon UI controls in the same state across all workbooks for Excel 2013 and Higher. Note that :
To get more details, see the source of this example: MSDN (opens new window). This also causes some trouble with modeless userforms. See Here (opens new window) for a solution. |
Read Article
https://develop.horje.com/learn/1434/reference