View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett Excel MVP Don Guillett Excel MVP is offline
external usenet poster
 
Posts: 168
Default writing macro to match the group and age

On Sep 21, 5:07*pm, ipek wrote:
i am trying to write a macro to match age &group

for example I am 19 and I am in the group 1 so I am trying to write
the macro to give the answer of which group I belong to

group 1:0-20 ages
group 2 :21-30 ages
group 3:31-40 ages
group 4: 41-50 ages

thanks


Option Explicit
Sub whichagegroup()
Dim x As Integer
Select Case ActiveCell
Case 0 To 20: x = 1
Case 21 To 30: x = 2
Case 31 To 40: x = 3
Case 41 To 50: x = 4
Case Else
MsgBox "What about us old folks?"
Exit Sub
End Select
MsgBox x
End Sub