Results 1 to 10 of 15

Thread: Copy row from one workbook to another workbook based on conditions in another Workbook

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #15
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10
    Solution ( attempt )
    This solution is based solely on the files from Post#1 and an attempt at the correct question below. Everything else form this post, and at the cross post, is ignored since the OP either
    has no idea about
    or is unwilling to give any information about the given macros
    and statements like “it works perfectly” or macro correction are invalid , unjustified, and are basically a lot of crap.



    The question is badly written , but we do have an Output , ( and an empty initial worksheet**) , so the question will be assumed to be:
    The data rows of 1.xls are considered, in particular the values in columns H and D
    _____ Workbook: 1.xls ( Using Excel 2007 32 bit )
    Row\Col D E F G H
    1 Open High Low Prev Close LTP
    2 2394.65 2417.35 2350 2394.65 2351.9
    3 156.75 161 150.05 156.8 159
    4 4113 4127.95 4037 4112.5 4058
    5 17090.05 17250 16700 17090.05 16700
    Worksheet: 1-Sheet1 15July 2020

    If column H of 1.xls is greater than column D of 1.xls then copy third row of orderformat.xlsx & paste it to basketorder.xlsx
    Else If column H of 1.xls is smaller than column D of 1.xls then copy first row of orderformat.xlsx & paste it to basketorder.xlsx


    _____ Workbook: OrderFormat.xlsx ( Using Excel 2007 32 bit )
    Row\Col A B C D E F G H I J K L M N O P Q R S T U
    1 NSE EQ NA NA NA 0 0 BUY MARKET NA CLI MIS DAY WC5758 NA 3 NA
    2 NSE EQ NA NA NA 0 0 SELL SL-M CLI MIS DAY WC5758 NA NA NA
    3 NSE EQ NA NA NA 0 0 SELL MARKET NA CLI MIS DAY WC5758 NA 3 NA
    4 NSE EQ NA NA NA 0 0 BUY SL-M CLI MIS DAY WC5758 NA NA NA
    Worksheet: Sheet1 15 July 2020

    ** I will assume the worksheet in BasketOrder.xlsx is empty initially.
    All worksheets are assumed to be the first tab worksheet ( Worksheets.Item(1) )
    Here is the given After Output:

    _____ Workbook: BasketOrder.xlsx ( Using Excel 2007 32 bit )
    Row\Col A B C D E F G H I J K L M N O P Q R S T U
    1 NSE EQ NA NA NA 0 0 SELL MARKET NA CLI MIS DAY WC5758 NA 3 NA
    2 NSE EQ NA NA NA 0 0 BUY MARKET NA CLI MIS DAY WC5758 NA 3 NA
    3 NSE EQ NA NA NA 0 0 SELL MARKET NA CLI MIS DAY WC5758 NA 3 NA
    4 NSE EQ NA NA NA 0 0 SELL MARKET NA CLI MIS DAY WC5758 NA 3 NA
    Worksheet: Output 15July BasketOrder

    ( Looking at the results, we see that the OP has got his logic and the Output after results the wrong way around. But that is typical. He is probably Autistic, or has some other brain defect: He often cannot distinguish between greater or smaller. All attempts to explain it to him fail ( https://excelfox.com/forum/showthrea...ll=1#post12848 ) )




    I have done a macro solution to satisfy the OP’s original given logic, https://excelfox.com/forum/showthrea...ll=1#post14718
    The basic code description is: We loop down the rows of 1.xls, checking if the column H value is greater or smaller than the column D value. Depending on the result we add a 1 or 3 to an array of indicia that we use in an array type Index calculation to give us the entire required output range in one go.
    The macro that satisfies the logic given by the OP, ( https://excelfox.com/forum/showthrea...ll=1#post14718 ) gives these results:


    _____ Workbook: BasketOrder.xlsx ( Using Excel 2007 32 bit )
    Row\Col A B C D E F G H I J K L M N O P Q R S T U
    1 NSE EQ NA NA NA
    0
    0
    BUY MARKET NA CLI MIS DAY WC5758 NA
    3
    NA
    2 NSE EQ NA NA NA
    0
    0
    SELL MARKET NA CLI MIS DAY WC5758 NA
    3
    NA
    3 NSE EQ NA NA NA
    0
    0
    BUY MARKET NA CLI MIS DAY WC5758 NA
    3
    NA
    4 NSE EQ NA NA NA
    0
    0
    BUY MARKET NA CLI MIS DAY WC5758 NA
    3
    NA
    Worksheet: Sheet1 15 July
    Last edited by DocAElstein; 07-26-2020 at 01:36 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    KILL A MODERATOR!!

Similar Threads

  1. Replies: 2
    Last Post: 07-07-2020, 05:42 PM
  2. Replies: 101
    Last Post: 06-11-2020, 02:01 PM
  3. Replies: 4
    Last Post: 04-10-2014, 10:58 PM
  4. Replies: 2
    Last Post: 09-18-2013, 12:30 AM
  5. Replies: 2
    Last Post: 05-28-2013, 05:32 PM

Tags for this Thread

Posting Permissions

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