Forum Discussion

ABro_1111's avatar
ABro_1111
Copper Contributor
Mar 05, 2023
Solved

VBA Code to Automatically Copy and Paste a Range of Data if the Criteria is Met

Hi,   I am looking for some help with a copy and paste code.  I want excel to determine if the values in one column is less than the values in another and if so, copy/paste those rows of data ...
  • OliverScheurich's avatar
    OliverScheurich
    Mar 06, 2023

    ABro_1111 

    =IFERROR(INDEX(Sheet2!D$81:D$86,SMALL(IF(Sheet2!$F$81:$F$86>Sheet2!$G$81:$G$86,ROW(Sheet2!$A$81:$A$86)-80),ROW($A1))),"")

    Without VBA you can try this formula. The formula has to be entered as an arrayformula with ctrl+shift+enter if one doesn't work with Office 365 or Excel 2021. In the example the formula is in cell H2 of sheet8 and filled across range H2:K8.

     

    Sheet2:

     

    Sheet8:

     

Resources