Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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.....
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Caling fortran from excel Rafael Tini Excel Programming 1 November 13th 07 08:45 PM
compaq visual fortran dll vbfortran Excel Programming 1 June 4th 07 02:18 PM
how can I import Fortran output to Excel? Ali Excel Programming 1 March 12th 05 11:35 PM
Calling a Fortran dll from Excel Tom Kreutz Excel Programming 0 November 15th 03 06:56 PM
Link to fortran Claudia[_3_] Excel Programming 0 September 18th 03 08:58 AM


All times are GMT +1. The time now is 02:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"