Jumat, 30 Desember 2011

[ExcelVBA] Implementing a Table in Visual Basic

 

Hello folks:

This is my first post in this group. Please excuse me if it's too long. I've tried searching previous posts and I don't find a clear illustration of what I'm trying to do.

I've been asked to write a Visual Basic function for an Excel Workbook that calculates dollars based on monthly water usage. Here's what the input table looks like:

Gallons per month Charge per 1,000 gallons
0 - 2,000 $3.75
2,000 - 5,000 $5.50
5,000 - 10,000 $7.40
10,000 - 25,000 $10.00
25,000 - 50,000 $15.00
50,000 - 200,000 $25.00

The function must calculate the total dollars based on a specified number of gallons used in a month.

I intend to include an area in the Workbook with 3 consecutive columns, say A1:A6 is 0, 2000, 5000, etc., B1:B6 is 2000, 5000, 10000, etc., and C1:C6 is 3.75, 5.50, 7.40, etc.

Regarding passing parameters to the Visual Basic function, I know how to pass the gallon usage as a double and return the calculated result as a double.

What's the easiest way to pass the ranges A1:A6, B1:B6, and C1:C6?

I'm an old C++ programmer so I can hack my way through the relevant Basic ocde to calculate the dollars.

If there's a post on this forum that demonstrates some of the principles I need to use here, I would appreciate your letting me know the reference.

Again, excuse the long post and I appreciate any help you can give me.
Best regards,
Graham

__._,_.___
Recent Activity:
----------------------------------
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.

----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA

----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com

----------------------------------
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

Tidak ada komentar:

Posting Komentar