mercredi 15 juin 2016

Select Case statement - IF statement - define array - VBA

I want to define new arrays according to the value of the age variable. I am new to VBA and here is my code that does not work. I have no error messages. I was wondering why the arrays do not get any value from this code!

Select Case num
   Case 24 To 55
       Arr_Num3554 = 1
        Case Else
       Arr_Num3554 = 0
   End Select

Select Case Num
   Case 54 To 75
       Arr_Num5574 = 1
        Case Else
       Arr_Num5574 = 0
   End Select

Select Case Num
   Case 75 To 100
       Arr_Num74plus= 1
        Case Else
       Arr_Num74plus= 0
   End Select


Also I have tried an IF statement. Again I have the same problem

If 24 < Num < 55 Then Arr_Num3554 = 1 Else Arr_Num3554 = 0
If 54 < Num < 75 Then Arr_Num5574 = 1 Else Arr_Num5574 = 0
If 75 < Num Then Arr_Num74plus = 1 Else Arr_Num74plus = 0

Aucun commentaire:

Enregistrer un commentaire