If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Visual Basic > VB coding help Excel

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-27-09, 14:06
schonel schonel is offline
Registered User
 
Join Date: May 2009
Posts: 9
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
Reply With Quote
  #2 (permalink)  
Old 05-27-09, 18:59
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
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 19:03.
Reply With Quote
  #3 (permalink)  
Old 05-27-09, 19:15
schonel schonel is offline
Registered User
 
Join Date: May 2009
Posts: 9
Thanks alot..will try with this one.

Many Thanks
Reply With Quote
  #4 (permalink)  
Old 05-27-09, 23:28
Ax238 Ax238 is offline
Registered User
 
Join Date: May 2009
Posts: 257
No problem, let me know if it helps.
Reply With Quote
  #5 (permalink)  
Old 05-28-09, 04:00
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
For reference, this is cross posted in the Excel board:

Excel IF and vlookup formulae
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On