Article View: alt.comp
Article #328Re: How to make my own formula in Excel (Visual Basic)
From: Thomas Ogilvy
Date: Tue, 23 Jun 1998 00:00
Date: Tue, 23 Jun 1998 00:00
63 lines
3094 bytes
3094 bytes
Peter
Public Function Costs(cell1 as text, cell2 as single, cell3 as single) as
Single
Dim result as single
dim P as single
' Your code here
' Assume your code is correct and final result is in the variable result
then
' that value must be assigned to the name of the function
Costs = Result
End Function
HTH,
Tom Ogilvy
Peter J. E. ROEK wrote in message <6mpaqe$fvr@news.euro.net>...
Dear reader,
Thanks for paying attention to this message.
Working in Excel, I want to design my own formula
with Visual Basic.
Can you tell me how to do this?
For example I want to make a formula named �COSTS�:
COSTS(cell1, cell2, cell3)
When I place this own-made formula in a certain cell, the
next procedure has to run:
(RESULT must be the result that has to appear in the cell
with the formula in it�.)
IF cell1 = �Bank� THEN
IF cell2 <= 1,50 THEN
IF cell3 <= 10 THEN P=12 ENDIF
IF cell3 >10 AND cell3 <=100 THEN P=9 ENDIF
IF cell3 > 100 THEN P=7.5 ENDIF
IF P*cell3 < 50 THEN RESULT=50 ELSE RESULT=P*cell3 ENDIF
ELSE
IF cell3 <= 10 THEN P=19 ENDIF
IF cell3 >10 AND cell3 <=100 THEN P=15 ENDIF
IF cell3 > 100 THEN P=12.5 ENDIF
IF P*cell3 < 50 THEN RESULT=50 ELSE RESULT=P*cell3 ENDIF
ENDIF
IF cell1 = �Phone� THEN
IF cell2 <= 1,50 THEN
IF cell3 <= 10 THEN P=11 ELSE P=6 ENDIF
IF P*cell3 < 50 THEN RESULT=50 ELSE RESULT=P*cell3
ELSE
IF cell3 <= 10 THEN P=16 ELSE P=11 ENDIF
IF P*cell3 < 50 THEN RESULT=50 ELSE RESULT=P*cell3
ENDIF
Thanks very much for your cooperation.
Peter Roek
Tel/Fax: (+31)165-514671
Mobile: (+31)653-639890
E-mail: roekp@westbrabant.net
Technical Details
Message-ID:
<eQ4Sldwn9GA.168@uppssnewspub05.moswest.msn.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<6mpaqe$fvr@news.euro.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10e5fa,d21d7b93b541e494 X-Google-Attributes: gid10e5fa,public X-Google-Thread: 107324,d21d7b93b541e494 X-Google-Attributes: gid107324,public X-Google-Thread: 1053fc,d21d7b93b541e494 X-Google-Attributes: gid1053fc,public X-Google-Thread: 103e02,d21d7b93b541e494 X-Google-Attributes: gid103e02,public X-Google-Thread: f87f8,d21d7b93b541e494 X-Google-Attributes: gidf87f8,public X-Google-Thread: ff2b1,d21d7b93b541e494 X-Google-Attributes: gidff2b1,public X-Google-Thread: 1082b6,d21d7b93b541e494 X-Google-Attributes: gid1082b6,public X-Google-Thread: 1127bd,d21d7b93b541e494 X-Google-Attributes: gid1127bd,public From: "Thomas Ogilvy" <twogilvy@email.msn.com> Subject: Re: How to make my own formula in Excel (Visual Basic) Date: 1998/06/23 Message-ID: <eQ4Sldwn9GA.168@uppssnewspub05.moswest.msn.net> X-Deja-AN: 365484236 References: <6mpaqe$fvr@news.euro.net> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 Newsgroups: alt.comp,alt.comp.lang.visulabasic.ver3,comp.sys.be.programmer,de.comp.sys.ibm-pc,es.comp.lenguajes.visual-basic,microsoft.public.excel.programming,nl.comp,nl.comp.programmeren,tw.bbs.comp.language