![]() |
How to branch?
Excel Experts:
My VBA skills allow me to delete columns, add numbers and such, but I don't know how to structure code to take different actions based on conditions. My spreadsheet is similar to the following: A B C 1 Existing Positions: 2 AMD 50 3 DELL 75 4 MSFT 100 5 New Trades: 6 Type Symbol Shares 7 ADD AMD 25 8 SELLPARTIAL DELL 50 9 SELLALL MSFT 100 I want my program to take a different action on an Existing Position, based on the Type of the New Trade. For the new trade in AMD, Type ADD, I want to add the 25 new shares to the existing 50 shares. For DELL, type SELLPARTIAL, I want to reduce the exising shares by 50. For MSFT, type SELLALL, I want to move the existing position to a different part of my spreadsheet. I think I want to use a Select Case structure, as I have 8 different Types. How would I structure the code? Thanks, Alan -- achidsey |
How to branch?
Certainly Select Case is a viable option.
See the help example for Select Case -- Regards, Tom Ogilvy "achidsey" (notmorespam) wrote in message ... Excel Experts: My VBA skills allow me to delete columns, add numbers and such, but I don't know how to structure code to take different actions based on conditions. My spreadsheet is similar to the following: A B C 1 Existing Positions: 2 AMD 50 3 DELL 75 4 MSFT 100 5 New Trades: 6 Type Symbol Shares 7 ADD AMD 25 8 SELLPARTIAL DELL 50 9 SELLALL MSFT 100 I want my program to take a different action on an Existing Position, based on the Type of the New Trade. For the new trade in AMD, Type ADD, I want to add the 25 new shares to the existing 50 shares. For DELL, type SELLPARTIAL, I want to reduce the exising shares by 50. For MSFT, type SELLALL, I want to move the existing position to a different part of my spreadsheet. I think I want to use a Select Case structure, as I have 8 different Types. How would I structure the code? Thanks, Alan -- achidsey |
All times are GMT +1. The time now is 11:00 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com