Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Chigaru Massri   on Feb 12 In MS Office Category.

  
Question Answered By: Saila Iqbal   on Feb 12

You said, "I have a cell"
did you actually mean that you have a column or group of cells?

I'd use the worksheet_change event.
test to see if the column is the one being watched
test to see if the value is NUMERIC!
divide the number  by 10, round  it off, multiply by 10 and put  it back

it would look like:

Private Sub Worksheet_Change(ByVal Target As Range)
If ((Not Intersect(Range(Target.Address), Range("C2:C1000")) Is Nothing))
Then
If (IsNumeric(Target.Value)) Then
If (Target.Value < 10) Then Range(Target.Address) = 10
Range(Target.Address) = Round(Target.Value / 10) * 10
Else
MsgBox "Value: " & Target.Value & " is not a number"
End If
End If
End Sub

Share: