+ Reply to Thread
Results 1 to 3 of 3

Macro to insert rows conditionally.

  1. #1
    Registered User
    Join Date
    04-08-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    2

    Macro to insert rows conditionally.

    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 here: http://www.mrexcel.com/forum/excel-q...itionally.html

  2. #2
    Valued Forum Contributor
    Join Date
    06-17-2009
    Location
    Chennai,India
    MS-Off Ver
    Excel 2003,excel 2007
    Posts
    678

    Re: Macro to insert rows conditionally.

    Had you given a small extract of data it would have been easier to prepare the macro. I have designed a sheet (sheet1) in the workbook attached. This is also copied to sheet3 repeat sheet3 to preserve original data.

    Three macros are there 1)test2)undo and 3)removeweedned
    First run undo so that you get original data
    Then run MACRO test. You need NOT run remove
    weekends because this is appended to macro test
    Now the dates are in serial order but week ends are removed. You may have to remove holidays also that is extension.

    I am attaching the file
    Attached Files Attached Files
    I am not an expert. better solutions may be available
    [email protected]

  3. #3
    Registered User
    Join Date
    04-08-2014
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    2

    Re: Macro to insert rows conditionally.

    Thank you so much, that's very kind of you. I can't seem to make it work though. I have attached a sample of the data like you suggested which could perhaps make it clearer what I mean? Sorry for not articulating it well enough originally.

    It would also be great to insert blank rows until the last date of market activity (seen on sheet2) after the last trade the trader makes in that market.

    Trades also take place on weekends and holidays.

    Thank you again venkat.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Insert Rows Conditionally
    By samsonuk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-19-2013, 07:06 PM
  2. [SOLVED] Macro to conditionally insert rows and fill them
    By dproth in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2013, 09:48 AM
  3. [SOLVED] Macro to conditionally hide/unhide rows
    By BeardedF in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-12-2012, 05:25 PM
  4. Conditionally insert rows, sum and average
    By menyanthe in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-10-2009, 04:54 AM
  5. How to remove blank rows, then insert blank row conditionally, PLUS error proof
    By GTS115 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-05-2009, 11:39 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1