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 > PC based Database Applications > Microsoft Excel > convert excel function to vba

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-22-10, 10:37
EDAR EDAR is offline
Registered User
 
Join Date: Sep 2003
Posts: 5
convert excel function to vba

I need to write the following function used in an excelsheet in vba, but my knowledge of excel is to weak to understand fully the formula. Can anybody help me ?

function:

=IF(AND(B31<TODAY();B32<TODAY();B33<TODAY();B34<TO DAY();OR(ISBLANK(B36);B36=2));2;IF(AND(B31<TODAY() ;B32<TODAY();B33<TODAY();B34<TODAY();B36=4);4;IF(O R(B31>TODAY();B32>TODAY();B33>TODAY();B34>TODAY(); AND(B31<TODAY();B32<TODAY();B33<TODAY();B34<TODAY( );B36 = 1));1;"error")))

Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 03-22-10, 12:38
Colin Legg Colin Legg is offline
Registered User
 
Join Date: Sep 2008
Location: London, UK
Posts: 495
Hi,

In VBA pseudocode, the formula translates to:
Code:
If (B31:B34 are all less than today) And ( either (B36 is empty) Or (B36 = 2) ) Then
    Function Value = 2
 
ElseIf (B31:B34 are all less than today) And (B36 = 4) Then
   Function Value = 4
 
ElseIf (Any of B31:B34 are greater than today) Or ( (B31:B34 are all less than today) And (B36 = 1) ) Then
    Function Value = 1
 
Else
   Function Value = "Error"
 
End If
Only you can tell whether or not the logic of that formula is correct!

Hope that helps..
__________________
Colin

RAD Excel Blog

Other tutorials:
Array Formulas | Deleting Rows with VBA

Last edited by Colin Legg; 03-22-10 at 12:41.
Reply With Quote
  #3 (permalink)  
Old 03-23-10, 02:22
EDAR EDAR is offline
Registered User
 
Join Date: Sep 2003
Posts: 5
Thanks Colin,
this was all I needed.

Eddy
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