Solved

create column to denote leg#

Posted on 2011-03-10
7
258 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now