Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi I need to create a function in VBA derived from an actual fortran coding:
ER_ELIG = .false. ERPOINTS = iage + vsvcb IF ((IGRP.eq.1).and.(iage.ge.55).and.(vsvcb.ge.10)) ER_ELIG = .true. IF ((IGRP.eq.2).and.(iage.ge.50)) ER_ELIG = .true. ERF = 0.00 IF (ER_ELIG) THEN IF (IGRP.eq.1) THEN IF (ERPOINTS.ge.75) then ERF = DIM ( 1. , .04*MIN(4,DIM(62,MAX(55,iage))) + .03*MIN(3,DIM(58,MAX(55,iage))) ) ELSE ERF = DIM ( 1. , .0667*MIN(5,DIM(65,MAX(55,iage))) + .0333*MIN(5,DIM(60,MAX(55,iage))) ) ENDIF IF (vsvcb.ge.25) ERF = 1.000 IF ((iage.ge.62).and.(ERPOINTS.ge.75)) ERF = 1.000 ELSE ERF = DIM ( 1. , .018*MIN(2,DIM(62,MAX(50,iage))) + .036*MIN(5,DIM(60,MAX(50,iage))) + .052*MIN(5,DIM(55,MAX(50,iage))) ) IF (iage.ge.62) ERF = 1.000 ENDIF ENDIF Any tips on how to? I am not as familiar in VBA..... |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
sylphide wrote:
Hi I need to create a function in VBA derived from an actual fortran coding: ER_ELIG = .false. ERPOINTS = iage + vsvcb IF ((IGRP.eq.1).and.(iage.ge.55).and.(vsvcb.ge.10)) ER_ELIG = .true. IF ((IGRP.eq.2).and.(iage.ge.50)) ER_ELIG = .true. ERF = 0.00 IF (ER_ELIG) THEN IF (IGRP.eq.1) THEN IF (ERPOINTS.ge.75) then ERF = DIM ( 1. , .04*MIN(4,DIM(62,MAX(55,iage))) + .03*MIN(3,DIM(58,MAX(55,iage))) ) ELSE ERF = DIM ( 1. , .0667*MIN(5,DIM(65,MAX(55,iage))) + .0333*MIN(5,DIM(60,MAX(55,iage))) ) ENDIF IF (vsvcb.ge.25) ERF = 1.000 IF ((iage.ge.62).and.(ERPOINTS.ge.75)) ERF = 1.000 ELSE ERF = DIM ( 1. , .018*MIN(2,DIM(62,MAX(50,iage))) + .036*MIN(5,DIM(60,MAX(50,iage))) + .052*MIN(5,DIM(55,MAX(50,iage))) ) IF (iage.ge.62) ERF = 1.000 ENDIF ENDIF Any tips on how to? I am not as familiar in VBA..... In a VBA pane type SUB FortranTest <enter Inside the resultig block paste your fortran s/.false./FALSE/ s/.true./TRUE/ s/.eq./=/ s/.ge./=/ s/DIM/DIMB/ (DIM is a reserved word in Basic) s/MIN/Application.WorksheetFunction.Min/ etc. Clumsy but they are intrinsic functions in Excel VBA. And then fix the remaining syntax errors. Beware that integer variables need to be declared explicitly in VBA or they will be stored as variants. Regards, Martin Brown |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Caling fortran from excel | Excel Programming | |||
compaq visual fortran dll | Excel Programming | |||
how can I import Fortran output to Excel? | Excel Programming | |||
Calling a Fortran dll from Excel | Excel Programming | |||
Link to fortran | Excel Programming |