Article View: alt.comp
Article #327How to make my own formula in Excel (Visual Basic)
From: Peter J. E. ROEK
Date: Tue, 23 Jun 1998 00:00
Date: Tue, 23 Jun 1998 00:00
130 lines
6008 bytes
6008 bytes
This is a multi-part message in MIME format.
------=_NextPart_000_0007_01BD9F08.56CEF380
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
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 =93COSTS=94:
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=85.)
IF cell1 =3D =93Bank=94 THEN
IF cell2 <=3D 1,50 THEN
IF cell3 <=3D 10 THEN P=3D12 ENDIF
IF cell3 >10 AND cell3 <=3D100 THEN P=3D9 ENDIF
IF cell3 > 100 THEN P=3D7.5 ENDIF
IF P*cell3 < 50 THEN RESULT=3D50 ELSE RESULT=3DP*cell3 ENDIF
ELSE
IF cell3 <=3D 10 THEN P=3D19 ENDIF
IF cell3 >10 AND cell3 <=3D100 THEN P=3D15 ENDIF
IF cell3 > 100 THEN P=3D12.5 ENDIF
IF P*cell3 < 50 THEN RESULT=3D50 ELSE RESULT=3DP*cell3 ENDIF
ENDIF
IF cell1 =3D =93Phone=94 THEN
IF cell2 <=3D 1,50 THEN
IF cell3 <=3D 10 THEN P=3D11 ELSE P=3D6 ENDIF
IF P*cell3 < 50 THEN RESULT=3D50 ELSE RESULT=3DP*cell3
ELSE
IF cell3 <=3D 10 THEN P=3D16 ELSE P=3D11 ENDIF
IF P*cell3 < 50 THEN RESULT=3D50 ELSE RESULT=3DP*cell3
ENDIF
Thanks very much for your cooperation.
Peter Roek
Tel/Fax: (+31)165-514671
Mobile: (+31)653-639890
E-mail: roekp@westbrabant.net
------=_NextPart_000_0007_01BD9F08.56CEF380
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>
<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.3110.2"' name=3DGENERATOR>
</HEAD>
<BODY>
<DIV><FONT size=3D1>Dear reader,</FONT></DIV>
<DIV><FONT size=3D1></FONT> </DIV>
<DIV><FONT size=3D1>Thanks for paying attention to this =
message.<BR>Working in=20
Excel, I want to design my own formula<BR>with Visual Basic.<BR>Can you =
tell me=20
how to do this?<BR>For example I want to make a formula named=20
“COSTS”:</FONT></DIV>
<DIV><FONT size=3D1></FONT> </DIV>
<DIV><FONT size=3D1>COSTS(cell1, cell2, cell3)</FONT></DIV>
<DIV><FONT size=3D1></FONT> </DIV>
<DIV><FONT size=3D1>When I place this own-made formula in a certain =
cell,=20
the<BR>next procedure has to run:</FONT></DIV>
<DIV><FONT size=3D1></FONT> </DIV>
<DIV><FONT size=3D1>(RESULT must be the result that has to appear in the =
cell<BR>with the formula in it….)</FONT></DIV>
<DIV><FONT size=3D1></FONT> </DIV>
<DIV><FONT size=3D1>IF cell1 =3D “Bank” =
THEN<BR> =20
IF cell2 <=3D 1,50 THEN<BR> IF cell3 =
<=3D 10=20
THEN P=3D12 ENDIF<BR> IF cell3 >10 AND =
cell3=20
<=3D100 THEN P=3D9 ENDIF<BR> IF cell3 =
> 100 THEN=20
P=3D7.5 ENDIF<BR> IF P*cell3 < 50 THEN =
RESULT=3D50=20
ELSE RESULT=3DP*cell3 ENDIF<BR> =20
ELSE<BR> IF cell3 <=3D 10 THEN P=3D19=20
ENDIF<BR> IF cell3 >10 AND cell3 =
<=3D100 THEN=20
P=3D15 ENDIF<BR> IF cell3 > 100 THEN =
P=3D12.5=20
ENDIF<BR> IF P*cell3 < 50 THEN =
RESULT=3D50 ELSE=20
RESULT=3DP*cell3 ENDIF<BR>ENDIF</FONT></DIV>
<DIV><FONT size=3D1></FONT> </DIV>
<DIV><FONT size=3D1>IF cell1 =3D “Phone”=20
THEN<BR> IF cell2 <=3D 1,50=20
THEN<BR> IF cell3 <=3D 10 THEN P=3D11 =
ELSE P=3D6=20
ENDIF<BR> IF P*cell3 < 50 THEN =
RESULT=3D50 ELSE=20
RESULT=3DP*cell3<BR> =
ELSE<BR> IF=20
cell3 <=3D 10 THEN P=3D16 ELSE P=3D11 =
ENDIF<BR> IF=20
P*cell3 < 50 THEN RESULT=3D50 ELSE =
RESULT=3DP*cell3<BR>ENDIF</FONT></DIV>
<DIV><FONT size=3D1></FONT> </DIV>
<DIV><FONT size=3D1><BR>Thanks very much for your =
cooperation.</FONT></DIV>
<DIV><FONT size=3D1></FONT> </DIV>
<DIV><FONT size=3D1>Peter Roek<BR>Tel/Fax: (+31)165-514671<BR>Mobile:=20
(+31)653-639890<BR>E-mail: <A=20
href=3D"mailto:roekp@westbrabant.net">roekp@westbrabant.net</A><BR></FONT=
></DIV></BODY></HTML>
------=_NextPart_000_0007_01BD9F08.56CEF380--
Technical Details
Message-ID:
<6mpaqe$fvr@news.euro.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 107324,d21d7b93b541e494,start X-Google-Attributes: gid107324,public X-Google-Thread: 10e5fa,d21d7b93b541e494,start X-Google-Attributes: gid10e5fa,public X-Google-Thread: 1082b6,d21d7b93b541e494,start X-Google-Attributes: gid1082b6,public X-Google-Thread: 103e02,d21d7b93b541e494,start X-Google-Attributes: gid103e02,public X-Google-Thread: f87f8,d21d7b93b541e494,start X-Google-Attributes: gidf87f8,public X-Google-Thread: 1053fc,d21d7b93b541e494,start X-Google-Attributes: gid1053fc,public X-Google-Thread: 1127bd,d21d7b93b541e494,start X-Google-Attributes: gid1127bd,public X-Google-Thread: ff2b1,d21d7b93b541e494,start X-Google-Attributes: gidff2b1,public From: "Peter J. E. ROEK" <roekp@westbrabant.net> Subject: How to make my own formula in Excel (Visual Basic) Date: 1998/06/23 Message-ID: <6mpaqe$fvr@news.euro.net> X-Deja-AN: 365455388 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0007_01BD9F08.56CEF380" X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.0 Organization: EuroNet Internet Mime-Version: 1.0 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