Howdy Folks,
I have a macro that shades vlaues in a table that are greater than a given number. It is used for comparing environmental chemistry data to governmental standards. for example:
Each field represents a cell in an Excel worksheet. My macro will shade 13 since it is larger than 5. However, it will not shade "6 J" because it interprets that cell as containing text. By the way, the "J" means the value is estimated. Okay, here's my question:
Is there a way to find cells that have "J*" values in them, separate the numerical portion of the cell, and then use that numerical portion for comparisson? If so, I would be might psyched. I included my code below. Thank you in advance for any help.
I have a macro that shades vlaues in a table that are greater than a given number. It is used for comparing environmental chemistry data to governmental standards. for example:
code:<HR>Code:Chemcial Standard value1 value2 value3 benzene 5 <5 13 6 J
Each field represents a cell in an Excel worksheet. My macro will shade 13 since it is larger than 5. However, it will not shade "6 J" because it interprets that cell as containing text. By the way, the "J" means the value is estimated. Okay, here's my question:
Is there a way to find cells that have "J*" values in them, separate the numerical portion of the cell, and then use that numerical portion for comparisson? If so, I would be might psyched. I included my code below. Thank you in advance for any help.
code:<HR>Code:Sub shadeExceed() Dim data Dim standardColumn 'Dialog box that asks the user for the data range and the column in which the standards reside. Set data = Application.InputBox(prompt:="Select data range", Type:=8) standardColumn = Application.InputBox(prompt:="Enter letter of column that contains the standards", default:="B") For Each datum In data rownumber = datum.Row colnumber = datum.Column 'Shade cells that are numbers, not null, and greater than the standard. If datum > Cells(rownumber, standardColumn) And IsNumeric(datum) = True And Cells(rownumber, standardColumn) <> "" And IsNumeric(Cells(rownumber, standardColumn)) Then With datum.Interior .ColorIndex = 15 .Pattern = xlSolid .PatternColorIndex = xlAutomatic End With End If '------------------------------- 'This is where I need some help '------------------------------- 'Rows were commented out cause they don't do what I need them to do. 'Conditional statement that shades any cells that have a J value, but do not have 'a less than sign in them 'If datum Like ("*J") And Not (datum Like "<*") Then 'With datum.Interior '.ColorIndex = 15 '.Pattern = xlSolid '.PatternColorIndex = xlAutomatic 'End With 'End If Next datum End Sub