ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   writing macro to match the group and age (https://www.excelbanter.com/excel-programming/443636-writing-macro-match-group-age.html)

ipek

writing macro to match the group and age
 
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

Don Guillett Excel MVP

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


All times are GMT +1. The time now is 03:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com