PDA

View Full Version : Macro for inserting new rows conditionally.



HarryC23
04-08-2014, 09:04 AM
Hi all,

I'm a bit stuck trying to use a macro for the first time. I've got a dataset of certain trades across different markets and traders, and on different days. The date of the trade is in column A, the contract ID is column D and the trader ID is column J.

Traders do not trade every day. I would like to insert a new row/rows for each date on which traders do not trade between their first and last trade, for each market in which they participate.

Is this possible using macros?

And, if so, then I would like to insert the high and low prices for the market on those dates from a different worksheet into the newly created blank rows. On this second workbook the contract ID is column A, the date is column C, the high price is column F and the low price is column E. I would like the low price to be inserted into column AJ on the original worksheet and the high price into column AK.

This second bit might be a bit trickier. Even if you could only help with the first part it really would be much appreciated.

Thanks,
Harry.

(n.b. I've also posted this on ExcelForum.com)

khu
04-08-2014, 09:09 AM
Any way to post a sample of the spreadsheet?

HarryC23
04-08-2014, 09:21 AM
11534

HarryC23
04-08-2014, 09:21 AM
Hi Khu, is that helpful?

HarryC23
04-08-2014, 09:24 AM
Sorry, that sample didn't capture that there are multiple traders in multiple markets.

khu
04-08-2014, 09:57 AM
It does, but I'm still trying to understand. So what you've posted shows trader 24182 did not trade between 21/12/2011 and 24/12/2011, when you say you want a row for EACH date they did not trade, do you want 3 new rows? or just one new row between trading periods? Or do they trade everyday, but not in the same market?

HarryC23
04-08-2014, 11:34 AM
Yes, I would like a new row for each missing date, for each market. They do not trade every day. Thank you!

HarryC23
04-09-2014, 09:28 AM
If there's anything else I can explain to help please let me know!