Wrox Programmer Forums
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 23rd, 2012, 04:51 AM
Registered User
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)

'Calculate invoice without discount

InvoiceAmount = Price * Volume
End If
End Function

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 11:12 AM
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

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.