Hi Jacolene,
a. As you have noticed, when you change a row and/or column VBA code does not adjust.
b. You need a way to uniquely identify the cells you want to treat specially. Methods to do this include:
(1) Background Color
(2) Text Value
(3) Location of the cell in relation to some known cel
(4) Font Characteristic (e.g. Name, Size, Bold, Italics, …)
c. In this case it seems like 'Font Color' is a good choice.
By changing one RGB index a small amount, we can generate a different color number that the human eye can't differentiate.
d. There is nothing wrong with merged cells, but they are occasionally difficult to work with using VBA.
In cases like yours, when it looks like you are only using one row and want to center the text, usng 'Center Across Selection' Formatting may be better suited (for future reference)
e. It looks like all your 'special cells' are constants (not formulas) so that makes them easier to work with.
f. I created 3 Main Macros to do what your want:
(1) aaaChangeFontColorOfSelectedCellsToRGB255_254_255() changes the Font Color of the Selected Cell or Cells (can be run using Alt F8)
(2) IdentifyAllOffWhiteFontsInWorkbook() Identifies all Cells that will Change Background Color (see Yellow CommandButton Shape on Sheet 'Edit')
(3) ChangeBackgroundColorforAllCellsWithOffWhiteFontInWorkbook() changes the Background Color of Cells with 'Off White' Font Color (see Yellow CommandButton Shape on Sheet 'Edit')
Current Font Color: vbWhite = 16777215 = RGB(255, 255, 255)
New Font Color for Selected Cells: 16776959 = RGB(255, 254, 255)
See the attached modified copy of your sample file which contains the following code in Ordinary Code Module ModChangeCellBackgroundColor:
To prevent typos from ruining days and weeks of work 'Option Explicit' is NEEDED at the top of each code module. This prevents errors caused by missspellings and FORCES every variable to be DECLARED (e.g. Dim i as Integer). http://www.cpearson.com/excel/DeclaringVariables.aspx
Lewis
Attachment deleted due to runtime error. See file associated with post #4 in this thread for corrected attachment. LJM
Bookmarks