Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
reneabesmer
 
Posts: n/a
Default how i can call the function

Hi .... i have a problem that how i can call a function in Excel VBA the
problem is.

public function price(item)

if(item = "apple") then
price =10
tax=0.2
elseif(item="orange") then
price =8
tax=0.5
end if
end function

But now how to get the exact tax number of apple which is 0.2
thanks in advance





  #2   Report Post  
Steve R
 
Posts: n/a
Default

I'd recommend against using a function in that way. It means a programmer is
required every time and item is added, a price changes or a tax rate
changes. Why not use a lookup instead?

http://www.techonthenet.com/excel/formulas/lookup.htm
http://www.cpearson.com/excel/lookups.htm

Steve

"reneabesmer" wrote in message
...
Hi .... i have a problem that how i can call a function in Excel VBA the
problem is.

public function price(item)

if(item = "apple") then
price =10
tax=0.2
elseif(item="orange") then
price =8
tax=0.5
end if
end function

But now how to get the exact tax number of apple which is 0.2
thanks in advance







  #3   Report Post  
Bob Phillips
 
Posts: n/a
Default

set up a table like so in say H1:K20

item price tax
apple 10 0.2
orange 8 .5
etc.

and us

=vlookup(A1,$H$1:$K$20,2,False)*VLOOKUP(A1,$H$1:$K $20,3,False)
--

HTH

RP
(remove nothere from the email address if mailing direct)


"reneabesmer" wrote in message
...
Hi .... i have a problem that how i can call a function in Excel VBA the
problem is.

public function price(item)

if(item = "apple") then
price =10
tax=0.2
elseif(item="orange") then
price =8
tax=0.5
end if
end function

But now how to get the exact tax number of apple which is 0.2
thanks in advance







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
clock Wildman Excel Worksheet Functions 2 April 26th 05 10:31 AM
Need a ISWorkday Function -- Any Ideas Mark Excel Worksheet Functions 5 March 29th 05 01:58 AM
Conversion SVC Excel Worksheet Functions 9 February 28th 05 02:29 PM
Using Function to call Woorbook Sheet Tahlmorrah Excel Discussion (Misc queries) 1 December 2nd 04 03:26 PM
How to call a function from another workbook Joe Excel Discussion (Misc queries) 4 November 26th 04 03:49 PM


All times are GMT +1. The time now is 03:59 PM.

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

About Us

"It's about Microsoft Excel"