Hi, I am new to VBA and need help finishing some code. I am trying to use ranges of incomes and the number of family members (i.e. 1, 2, 3, 4…) to calculate a percentage to see if families qualify for our program. This is because we have to refer to a chart with different income to family member ratios. I am using two different macros, the first triggers the second. On the second macro “NestedIf-Income”, I need to put code in at the end of each If statement which will factor in the number of family members for each row that has the respected family. Currently, I have “And Cells (14, 24) = 1” in that section. I do not know how to expand this range and still make it so that this code will be conscious of each row’s number of family members. Please help me out!
If Not Application.Intersect(Range("A1:A6"), Range(Target.Address)) Is Nothing Then
Call NestedIf_Income
End If
End Sub
Sub NestedIf_Income()
'Variable declaration
Dim Income As String
'Accepting the Percentage by the user
Income = InputBox("Enter the Income:", "Income")
If Income < 11499 And Cells(14, 24) = 1 Then
'Check if the Less than 30%
MsgBox "Income : Less than 30%"
ElseIf Income >= 11500 And Income < 113412 And Cells(14, 24) = 1 Then
'Check if the Income is 30%
MsgBox "Income : 30%"
ElseIf Income >= 13413 And Income < 17237 And Cells(14, 24) = 1 Then
'Check if the Income is 40%
MsgBox "Income : 40%"
ElseIf Income >= 17238 And Income < 21065 And Cells(14, 24) = 1 Then
'Check if the Income is 50%
MsgBox "Income : 50%"
ElseIf Income >= 21066 And Income < 24897 And Cells(14, 24) = 1 Then
'Check if the Income is 60%
MsgBox "Income : 60%"
ElseIf Income >= 21066 And Income < 24897 And Cells(14, 24) = 1 Then
'Check if the Income is 70%
MsgBox "Income : 70%"
ElseIf Income >= 21066 And Income < 24897 And Cells(14, 24) = 1 Then
'Check if the Income is 80%
MsgBox "Income : 80%"
ElseIf Income >= 21066 And Income < 24897 And Cells(14, 24) = 1 Then
'Check if the Income is More than 80%
MsgBox "Income : More than 80%"
Else
'Check if the Income has fail
MsgBox "Income : Need Percentage"
End If
End Sub
If Not Application.Intersect(Range("A1:A6"), Range(Target.Address)) Is Nothing Then
Call NestedIf_Income
End If
End Sub
Sub NestedIf_Income()
'Variable declaration
Dim Income As String
'Accepting the Percentage by the user
Income = InputBox("Enter the Income:", "Income")
If Income < 11499 And Cells(14, 24) = 1 Then
'Check if the Less than 30%
MsgBox "Income : Less than 30%"
ElseIf Income >= 11500 And Income < 113412 And Cells(14, 24) = 1 Then
'Check if the Income is 30%
MsgBox "Income : 30%"
ElseIf Income >= 13413 And Income < 17237 And Cells(14, 24) = 1 Then
'Check if the Income is 40%
MsgBox "Income : 40%"
ElseIf Income >= 17238 And Income < 21065 And Cells(14, 24) = 1 Then
'Check if the Income is 50%
MsgBox "Income : 50%"
ElseIf Income >= 21066 And Income < 24897 And Cells(14, 24) = 1 Then
'Check if the Income is 60%
MsgBox "Income : 60%"
ElseIf Income >= 21066 And Income < 24897 And Cells(14, 24) = 1 Then
'Check if the Income is 70%
MsgBox "Income : 70%"
ElseIf Income >= 21066 And Income < 24897 And Cells(14, 24) = 1 Then
'Check if the Income is 80%
MsgBox "Income : 80%"
ElseIf Income >= 21066 And Income < 24897 And Cells(14, 24) = 1 Then
'Check if the Income is More than 80%
MsgBox "Income : More than 80%"
Else
'Check if the Income has fail
MsgBox "Income : Need Percentage"
End If
End Sub