Select Case
I am trying to us a Select Case Construction but I am not able to get the
program to choose the branch.
I have a spreadsheet similar to the following:
A B C D
E
1 Old
2 Symbol Shares TotalShares
3 AMD 50
4
5 - New Trade -
6 Trade Type Symbol New Shares
7 ADD AMD 25
8
I want my code to put a value in cell below "TotalShares" (D3) based on the
entry in the cell below Trade Type (A7).
If the Trade Type is:
"ADD", add New Shares to Old Shares.
"SELLPARTIAL", subtract New Shares from Old Shares
"SELLALL", subtract New Shares from Old Shares and enter "sold" in E3
Here is my code.
My problem is that I want it to execute the statements below Case Add but it
skips over that code. I don't know how to indicate that this is Case ADD.
How to I fix this? Thanks, Alan
Sub ProcessTrades()
Dim TrType As Range
Dim OldShares As Range
Dim TradeShares As Range
Dim TotalShares As Range
Set OldShares = Range("C3")
Set TradeShares = Range("C7")
Set TotalShares = Range("D3")
Set TrType = Range("A7")
Select Case TrType
Case Add
TotalShares.Value = OldShares.Value + TradeShares.Value
Case SellPartial
TotalShares.Value = OldShares.Value - TradeShares.Value
Case SellAll
TotalShares.Value = OldShares.Value - TradeShares.Value
Range(E3).Value = "sold"
End Select
End Sub
achidsey
|