Page 745 - Excel 2013 All-in-One For Dummies
P. 745
Using the Visual Basic Editor 727
Figure 2-3:
Using the Find feature to locate the code to edit in the Code window.
After you enter the Visual Basic property or statement as your search string in the Find What text box, select the search options, and click the Find Next button, Excel attempts to locate its first occurrence in the code. When it does, the program highlights that occurrence in the current procedure, module, VBA project, or selected text block (depending on which Search option you use). To find the next occurrence, you can click the Find Next button in the Find dialog box again or, if you close this dialog box, press F3.
If you have a number of occurrences throughout the macro that require the same type of updating, you can use the Replace feature to both find and replace them in the macro code. This is particularly useful when you decide to change a particular value throughout a macro (such as selecting the cell range named “income_08” for processing instead of the range “income_07”), and you want to make sure that you don’t miss any occurrences.
To open the Replace dialog box, choose Edit➪Replace on the Visual Basic Editor menu bar or press Ctrl+H. Note that you can open the Replace dialog box from within the Find dialog box by clicking its Replace button.
The Replace dialog box that appears is just like the Find dialog box, except that it contains a Replace With text box along with the Find What text box and has Replace and Replace All buttons in addition to the Find Next button. After entering the property or statement to find in the Find What text box
Book VIII Chapter 2
VBA Programming