View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
spolk[_5_] spolk[_5_] is offline
external usenet poster
 
Posts: 1
Default Changing numbers to characters by using range values

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
< 2 Then
Worksheets("Horizon_Measurements").Cells(grv, "S").Value = "C"
ElseIf Worksheets("Horizon_Measurements").Cells(grv, "S").Value
< 5 Then
Worksheets("Horizon_Measurements").Cells(grv, "S").Value = "F"
ElseIf Worksheets("Horizon_Measurements").Cells(grv, "S").Value
< 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 pu
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