Solved

create column to denote leg#

Posted on 2011-03-10
7
260 Views
Last Modified: 2012-05-11
I need a macro that will make a new output tab with a new column for the trade history section of the original tabs (pm or rm).  Each row is considered a leg.  I need the new column to denote a number for each leg of any spread type and start over with the next symbol.  An example of what this might look like is shown here in the third column >> http://screencast.com/t/WF0hnvqi8pon

Note that the third column is not there by default and is created based on the spread.  If it is a multi-legged spread, the column shows the number of legs.  If it is a single-legged spread, it only shows one leg.
trade-macro-v2.1c.xlsm
0
Comment
Question by:rtod2
  • 4
  • 3
7 Comments
 
LVL 22

Expert Comment

by:rspahitz
ID: 35110145
Could you use a formula instead?  Something like this? (starting in cell C2)


=IF(AND(B2<>"",B2<>0),"Leg1","Leg"&IF(C1="",1,(VALUE(MID(C1&"   0",4,3))+1)))
0
 

Author Comment

by:rtod2
ID: 35110292
That certainly doesn't create an output tab.  Macro still needed.
0
 
LVL 22

Accepted Solution

by:
rspahitz earned 500 total points
ID: 35110381
sorry, I guess I don't understand your request.
if you create a new tab on the workbook, what do you want in it?

VBA code to create a new tab:

Sub AddOutputSheet()
    Sheets.Add After:=Sheets(Sheets.Count)
    Sheets(Sheets.Count).Name = "Output"
End Sub
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:rtod2
ID: 35110545
Ah, ok
Yeah I was wanting it to extract the trade history section and add a new row to the trade history.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 35110627
so you're looking to create a new tab called "rm output" that does the same thing that pm output does?
At this point, I don't see the correlation between pm and pm-output so I wouldn't know how to make the rm output's data.

It seems you may need to break this down into smaller tasks (possibly with separate questions) such as:
1) search through the rm sheet looking for TYPE TRD in column C and place the corresponding value into a new tab called rm output
2) add a new column C in rm output called leg and populate it with "LEG" followed by a number there the number starts at 1 and increases by 1 every time the corresponding value in column B is blank

etc.
0
 

Author Comment

by:rtod2
ID: 35110663
Yeah, just looking for it to extrapolate that section from either pm or rm and create the new column.
0
 

Author Comment

by:rtod2
ID: 35111424
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question