writing macro to match the group and age

I

ipek

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
 
D

Don Guillett Excel MVP

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top