Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Excel 2007 VBA Programmer's Reference ISBN: 978-0-470-04643-2
This is the forum to discuss the Wrox book Excel 2007 VBA Programmer's Reference by John Green, Stephen Bullen, Rob Bovey, Michael Alexander; ISBN: 9780470046432
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Excel 2007 VBA Programmer's Reference ISBN: 978-0-470-04643-2 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 23rd, 2012, 05:51 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default UDF command reference

I am just studying Excel 2007 VBA programmer's Reference book. On that chaper 1: Primer in Excel VBA there is a UDF example as below.
In the command line InvoiceAmount = Price * DiscountVolume + Price * _
(1 - DiscountPct) * (Volume - DiscountVolume
)

what the command (1 - DiscountPct) refers. What the command meaning to (1 - DiscountPct). Can someone explain to me?

Function InvoiceAmount(Product, Volume)

'Create object variable reffering to table in worksheet

Set Table = ThisWorkbook.Worksheets("Sheet1").Range("A2:D5")

'Find price in table

Price = WorksheetFunction.VLookup(Product, Table, 2)

'Find discount volume threshold

DiscountVolume = WorksheetFunction.VLookup(Product, Table, 3)

'Appy discount if volume above threshold

If Volume > DiscountVolume Then

'Calculate invoice with discount

DiscountPct = WorksheetFunction.VLookup(Product, Table, 4)
InvoiceAmount = Price * DiscountVolume + Price * _
(1 - DiscountPct) * (Volume - DiscountVolume)
Else

'Calculate invoice without discount

InvoiceAmount = Price * Volume
End If
End Function
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
UDF not passing value RG2010 Access 3 November 14th, 2010 04:34 PM
UDF references DavidReese BOOK: Excel 2007 VBA Programmer's Reference ISBN: 978-0-470-04643-2 0 November 2nd, 2008 11:04 AM
trying to run an udf miguel.ossa SQL Server 2005 7 July 22nd, 2007 12:12 PM
UDF: allowed in one DB but not another??? ea SQL Server 2000 2 January 18th, 2005 03:14 PM
UDF and Stored Procedures hrishimusale SQL Server 2000 1 November 4th, 2003 12:07 PM



All times are GMT -4. The time now is 04:37 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.