![]() |
Need Macro Fortran to VBA
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..... |
Need Macro Fortran to VBA
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 |
All times are GMT +1. The time now is 09:47 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com