Easy Excel Question

ghuughes93

New Member
Joined
Aug 6, 2014
Messages
10
Hi everybody. New to this forum. :)

I just have a really quick question about Class Modules. The only problem is I am clueless with Excel and have a deadline for tomorrow to do this exercise for.

I have about 5000 rows of data like this:

DirectionQuantityPrice
B40012.75
B10019.53
S90038.34
B1009.56

<colgroup><col width="64" span="3" style="width:48pt"> </colgroup><tbody>
</tbody>

B = buy and S = sell. I need to work out the total value. If the direction is buy (i.e. you're spending money) it should be a minus figure. If it's sell (i.e. you're gaining money) it should be a positive figure.

The cash associated with every row is Quantity*Price. So for the first one it's -(400*12.75) and for the third its 900*9.56. I need to output the total net cash (sum of the cash) from the trades in the spreadsheet in a Message Box.

I can't tell you how stuck I am right now and would greatly greatly appreciate any help.

Thank you in advance if anyoncan give me any direction!
 
Hi iyyi.

Thanks for your reply. I would love to tell you if this is working or not but I have no idea what to do once all the text is written in the Class Module.

Do I click the run button? I'm doing that but it's doing nothing.

Thanks again,
Gareth

And I'm still at a loss as to where the Function cash_of_trade() Double comes into it!
 
Last edited:
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Finally just managed to get the message box to output something but it was by sheer luck!

I ran the macro and it came up with another box. I pressed run on that and it worked.

Since then I've been doing the same thing over and over but I haven't managed to get it to work again.

Any ideas?

Thanks a lot.
Gareth
 
Upvote 0
Hey ghuughes93,

Sorry about the late response, I just got home from work.

To answer your question about taking into account Direction in column "A", Quantity in B and Price in C:
Yes it does. I set direction equal to column A. Then basically it loops through each cell in A and take the cell to the right of it, and then cell 2 cells to the right of it, and multiplies them. If "A" is B it subtracts from the running total, and if "A" is S then it adds to the running total.

To answer your other question, I'm not entirely sure. I didn't see your additional information until after I posted the code this morning. I have never used a Class Module. Also, as far as I know, adding "Function cash_of_trade()" would just create a user defined formula (UDF) that you would call in the worksheet, which isn't capable of generating a MsgBox to my knowledge (because as far as I know, Functions are only able to do calculations and can't actually manipulate the workbook in any way.)

Also, it doesn't compile to have "Double" after the initiation of "Function cash_of_trade()" so I'm not sure why it would show in the directions like that...


I'm kind of confused on the directions you have been given, maybe someone else on here who has used Class Modules can answer better, but from the little I know, that prompt doesn't make sense.


Sorry,
Alex
 
Upvote 0
This looks very much like an assignment !!.....:rolleyes:
 
Upvote 0

Forum statistics

Threads
1,221,418
Messages
6,159,791
Members
451,589
Latest member
Harold14

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top