Results 1 to 5 of 5
  1. #1
    Join Date
    May 2009
    Posts
    9

    Unanswered: VB coding help Excel

    GOod day all i am tryin to connvert this excel formulae in VB coding. Any help is mush appreciated.

    =(IF(A6<>"individual",IF(B6>=50,30,IF(AND(B6>=25,B 6<=49),20,IF(AND(B6>=15,B6<=24),15,IF(AND(B6>=5,B6 <=14),10,IF(B6<5,5,0))))),IF(B6>=25,25,IF(AND(B6>= 5,B6<=24),15,IF(B6<5,0,"-")))))/100


    Many Thanks

    Schon

  2. #2
    Join Date
    May 2009
    Posts
    258
    This might get you close, although the "-", if it could happen, would give you a "Type Mismatch" error:
    Code:
    If A6 <> "individual" Then
        Select Case B6
            Case Is >= 50: var = 30
            Case 25 To 49: var = 20
            Case 15 To 24: var = 15
            Case 5 To 14: var = 10
            Case Is < 5: var = 5
            Case Else: var = 0
        End Select
    Else
        Select Case B6
            Case Is >= 25: var = 25
            Case 5 To 24: var = 15
            Case Is < 5: var = 0
            Case Else: var = "-"
        End Select
    End If
    
    var = var / 100
    You can just change:
    Case Is < 5: var = 0
    Case Else: var = "-"

    To:
    Case Else: var = 0

    Ax
    Last edited by Ax238; 05-27-09 at 20:03.

  3. #3
    Join Date
    May 2009
    Posts
    9
    Thanks alot..will try with this one.

    Many Thanks

  4. #4
    Join Date
    May 2009
    Posts
    258
    No problem, let me know if it helps.

  5. #5
    Join Date
    Sep 2008
    Location
    London, UK
    Posts
    511
    For reference, this is cross posted in the Excel board:

    http://www.dbforums.com/microsoft-ex...-formulae.html

Posting Permissions

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