Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello, I was able to run a macro perfectly well using Strings that included spaces and dashes using the following code within Excel 2007, but not within Excel 2003. In Excel 2003 the following code only worked for Single character strings with no spaces, dashes, etc. Is there an easy change of the following code to make it work for a string such as "MD - Not Started", i.e., with spaces, so it will work in 2003 as well. This is a surprising and strange discrepancy between the two versions. [ Sub Final_colorcode_norecord() 'Variables for counting through cells Dim RowCount As Integer Dim ColumnCount As Integer Dim RowMax As Integer Dim ColMax As Integer Dim colorRed As String Dim colorYellow As String Dim colorGreen As String 'find the max row and col of the active worksheet RowMax = ActiveSheet.UsedRange.Rows.Count ColMax = ActiveSheet.UsedRange.Columns.Count 'Ask for text to account for colorRed = InputBox("Enter the string of text that will result in a RED Cell Coloring:", "Red Coloring") colorYellow = InputBox("Enter the string of text that will result in a YELLOW Cell Coloring:", "Yellow Coloring") colorGreen = InputBox("Enter the string of text that will result in a GREEN Cell Coloring:", "Green Coloring") 'nested for loops for counting through 2d cell grid For RowCount = 1 To RowMax For ColumnCount = 1 To ColMax 'check cell text for color red string If Cells(RowCount, ColumnCount).Text = colorRed Then Cells(RowCount, ColumnCount).Interior.Color = RGB(255, 0, 0) 'Red End If 'check cell text for color yellow string If Cells(RowCount, ColumnCount).Text = colorYellow Then Cells(RowCount, ColumnCount).Interior.Color = RGB(255, 255, 0) 'Yellow End If 'check cell text for color green string If Cells(RowCount, ColumnCount).Text = colorGreen Then Cells(RowCount, ColumnCount).Interior.Color = RGB(0, 255, 0) 'Green End If Next ColumnCount Next RowCount End Sub ] TIA, Brian |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Print Preview Discrepancy | Excel Discussion (Misc queries) | |||
Finance functions discrepancy | Excel Worksheet Functions | |||
Format Cells - Accounting - Discrepancy? | Excel Discussion (Misc queries) | |||
Font discrepancy | New Users to Excel | |||
Vlookup data discrepancy | Excel Discussion (Misc queries) |