+ Reply to Thread
Results 1 to 8 of 8

Formula to Copy/Paste data based on value of another cell, skipping zeros value & blanks

  1. #1
    Registered User
    Join Date
    04-25-2013
    Location
    Phils
    MS-Off Ver
    Office Professional Plus 2016
    Posts
    46

    Formula to Copy/Paste data based on value of another cell, skipping zeros value & blanks

    Hi,

    I spent the whole day to figure out a formula that does exactly one thing: copy (from sheet1) and paste data (to sheet2) a number of times depending on a value in an adjacent column. I searched several forum site and stumbled upon a VBA codes but I prefer a formula.

    For instance:

    Sheet1
    Product Code(A) Product Name(B) QTY(C) Price(D)
    02362 USB Drive 3 $1.75
    03516 HDD 2 $23.50
    06251 HDD Enclosure 0 $25.25
    07542 LCD Monitor 2 $125.25
    09561 Asus Netbook 0 $150

    In Sheet2, in columns A and B only, the following show be the results:
    Product Code (A) Product Name (B)
    02362 USB Drive
    02362 USB Drive
    02362 USB Drive
    03516 HDD
    03516 HDD
    07542 LCD Monitor
    07542 LCD Monitor

    Can you please help me for the formula in column A and B in sheet 2 to get the desired results above?

    Regards,
    kolokoy

  2. #2
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Formula to Copy/Paste data based on value of another cell, skipping zeros value & blan

    try below in sheet2 in A2
    copy paste then hold control and shift together and the hit enter
    =INDEX(Sheet1!A$2:A$6,MATCH(TRUE,MMULT(--(ROW(Sheet1!$A$2:$A$6)>=TRANSPOSE(ROW(Sheet1!$A$2:$A$6))),Sheet1!$C$2:$C$6)>=ROW(A1),0))
    drag down and drag to right

    change the references according to your data

    Another way is to use helper column
    in E1 of data sheet copy paste below formula
    =SUM($C$2:C2) and drag down till you have data.
    then in sheet2 A2 copy paste below then hold control and shift together and then hit enter to make it array formula.
    =IF(ROW(A1)>MAX(Sheet1!$E$2:$E$6),"",INDEX(Sheet1!A$2:A$6,MIN(IF(ROW(A1)=<Sheet1!$E$2:$E$6,ROW(Sheet1!$E$2:$E$6)-1))))
    drag down and drag to right
    Last edited by hemesh; 05-27-2014 at 09:19 AM.
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    WANT TO SAY THANKS, HIT ADD REPUTATION (*) AT THE BOTTOM LEFT CORNER OF THE POST

    More we learn about excel, more it shows us, how less we know about it.

    for chemistry
    https://www.youtube.com/c/chemistrybyshivaansh

  3. #3
    Registered User
    Join Date
    04-25-2013
    Location
    Phils
    MS-Off Ver
    Office Professional Plus 2016
    Posts
    46

    Re: Formula to Copy/Paste data based on value of another cell, skipping zeros value & blan

    Hi hemesh,

    Thank you for the quick reply. It is indeed a very complex formula to me. However, the result only copied the data twice. Here is a screen shot:
    Untitled.png

    It appears that the problem is only in the first row, it is always 1 less than the copied data. For instance, I tried to change Sheet1 A2 to 5, it only copied the data 4 times. While the rows below it are correct.

    Thank you very much.

    Regards,
    kolokoy

  4. #4
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Formula to Copy/Paste data based on value of another cell, skipping zeros value & blan

    updated the formula now try

  5. #5
    Registered User
    Join Date
    04-25-2013
    Location
    Phils
    MS-Off Ver
    Office Professional Plus 2016
    Posts
    46

    Re: Formula to Copy/Paste data based on value of another cell, skipping zeros value & blan

    Hi hemesh,

    Thank you very much. I tried the approach with the helper column. However, for the first row, USB Drive with QTY 3, the data were copied two times only and another one at the bottom of the list. So it is 3 in total, which is right, but is there a way to list the 3 USB drives like the other rows?

    See screen shot:
    Untitled2.png

    Thank you very much for your help!

    Regards,
    kolokoy

  6. #6
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Formula to Copy/Paste data based on value of another cell, skipping zeros value & blan

    find attached hope this helps
    Attached Files Attached Files
    Last edited by hemesh; 05-27-2014 at 12:22 PM.

  7. #7
    Registered User
    Join Date
    04-25-2013
    Location
    Phils
    MS-Off Ver
    Office Professional Plus 2016
    Posts
    46

    Re: Formula to Copy/Paste data based on value of another cell, skipping zeros value & blan

    Thank you hemesh for a very quick solution! It is exactly doing what I described now! Thank you very much! I will now mark this SOLVED.

    Regards,
    kolokoy

  8. #8
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Formula to Copy/Paste data based on value of another cell, skipping zeros value & blan

    You are welcome and Thanks for the feedback.

+ 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. Copy Contents of Cell Without Zeros for Blanks
    By financeanalyst in forum Excel General
    Replies: 3
    Last Post: 04-02-2014, 12:19 PM
  2. [SOLVED] Copy data from one sheet to another while skipping blanks and certain rows
    By gawk1980 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-15-2013, 07:34 AM
  3. [SOLVED] Copy data from one sheet to another while skipping blanks and certain rows
    By gawk1980 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-14-2013, 01:21 PM
  4. Copy Paste Macro with Values & Skipping Blanks
    By Blockey in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-30-2012, 08:24 AM
  5. [SOLVED] Paste Special Skip Blanks not skipping blanks, but overwriting...
    By gsrosin in forum Excel General
    Replies: 0
    Last Post: 02-22-2005, 12:06 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