Consulting

Results 1 to 14 of 14

Thread: Wrong result of my macro!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Wrong result of my macro!

    Hello!

    I would like to ask you what is wrong in my code, because I do not know what happened.
    In the table I have 2 columns: Salary and Has Kids (Do someone have children?).
    My macro take Salary and answer from columns Has Kids (Yes or No) and give particularly TaxRate.
    I have problem because for example: If I have Salary 3000 and "Yes" in columns Has Kids, macro give me that result: 0.01 (It should be 0).
    Please help me, because I do not know what do I wrong.
    Sorry for my English mistakes
    Function getTaxRateElseNestedIF(Salary As Double, HasKids As String) As Double
        If Salary > 5000 And Salary < 40000 Then
            If HasKids = "Yes" Then
            getTaxRateElseNestedIF = 0.15
            Else
            getTaxRateElseNestedIF = 0.25
            End If
        ElseIf Salary >= 40000 And Salary < 90000 Then
            If HasKids = "Yes" Then
            getTaxRateElseNestedIF = 0.28
            Else
            getTaxRateElseNestedIF = 0.35
            End If
        ElseIf Salary > 90000 Then
            If HasKids = "Yes" Then
            getTaxRateElseNestedIF = 0.42
            Else
            getTaxRateElseNestedIF = 0.45
            End If
        Else
            If HasKids = "Yes" Then
            getTaxRateElseNestedIF = 0
            Else
            getTaxRateElseNestedIF = 0.01
            End If
        End If
    End Function
    Last edited by Paul_Hossler; 01-18-2018 at 12:19 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •