Maybe just a general idea. You did not specify which value to use when the
value is exactly 2, 5, 15 ...etc. With "C" listed twice, this makes it
difficult to arrive at a simpler equation.
Sub Demo()
Dim Rng As Range
Dim Cell As Range
Dim LookFor
Dim ReturnValue
LookFor = Array(0, 0.00001, 2, 5, 15, 40, 90)
ReturnValue = Array("N", "C", "F", "C", "M", "A", "D")
On Error Resume Next
Set Rng = Columns("S:S").SpecialCells(xlCellTypeConstants, xlNumbers)
If Rng Is Nothing Then Exit Sub
With WorksheetFunction
For Each Cell In Rng.Cells
Cell.Value = .Lookup(Cell.Value, LookFor, ReturnValue)
Next Cell
End With
End Sub
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =
"spolk " wrote in message
...
Hi now I faced a new problem:
I wanted to make the following system
If in Column A values a
Value=0 ,will be changed to N
Value 0 and < 2 will be changed to V
Value 2 and < 5 will be changed to F
Here is my code
'Here is determined stone/gravel abundance sbhm_stgr/sbhe_stgr
Dim grv As Long
Application.ScreenUpdating = False
For grv = 1 To Worksheets("Horizon_Measurements").Cells(Rows.Coun t,
"S").End(xlUp).Row
If (Cells(grv, "S").Value) = 0 Then
Worksheets("Horizon_Measurements").Cells(grv, "S").Value = "N"
ElseIf Worksheets("Horizon_Measurements").Cells(grv, "S").Value 0
< 2 Then
Worksheets("Horizon_Measurements").Cells(grv, "S").Value = "C"
ElseIf Worksheets("Horizon_Measurements").Cells(grv, "S").Value 2
< 5 Then
Worksheets("Horizon_Measurements").Cells(grv, "S").Value = "F"
ElseIf Worksheets("Horizon_Measurements").Cells(grv, "S").Value 5
< 15 Then
Worksheets("Horizon_Measurements").Cells(grv, "S").Value = "C"
ElseIf Worksheets("Horizon_Measurements").Cells(grv, "S").Value
15 < 40 Then
Worksheets("Horizon_Measurements").Cells(grv, "S").Value = "M"
ElseIf Worksheets("Horizon_Measurements").Cells(grv, "S").Value
40 < 90 Then
Worksheets("Horizon_Measurements").Cells(grv, "S").Value = "A"
ElseIf Worksheets("Horizon_Measurements").Cells(grv, "S").Value
90 Then
Worksheets("Horizon_Measurements").Cells(grv, "S").Value = "D"
End If
Next grv
This code produces characters but not correctly, for example if I put
the value 91 to cell S2 the macro gives letter C instead of letter D .
My code works somehow, but not properly, what i'am doing wrong?
---
Message posted from http://www.ExcelForum.com/