Forum Discussion

AShah16's avatar
AShah16
Copper Contributor
Feb 08, 2022

Copy and Duplicate cells from based on column value from 1 sheet to another sheet

Hello All,

I want to copy the values of 2 columns based on a value in a 3rd column. The values should be duplicated based on the value in the 3rd column. The input data and output data are in different sheets. Please see the pictures below. What could be done to automate this process. A VBA Code perhaps?

 

Thanks

3 Replies

  • Riny_van_Eekelen's avatar
    Riny_van_Eekelen
    Platinum Contributor

    AShah16 Consider Power Query (PQ) to do this. Demonstrated in the attached file. The green table is the table loaded by PQ. In this example I loaded it in the same sheet as the blue table but you can load it to another sheet as well.

     

     

    • AShah16's avatar
      AShah16
      Copper Contributor
      Hello Riny_van_Eekelen,
      Thanks for your kind reply. In my case the number of Bins may change based on the user input. If the bins change i will probably need to refresh the query to update the output table. I was wondering if there is a way that as the user updates the Bins the output table is updated instantly and automatically.

      Thanks a lot again.
      • Riny_van_Eekelen's avatar
        Riny_van_Eekelen
        Platinum Contributor

        AShah16 You can write a piece of VBA code that will refresh the query as soon as something in the sheet changes. But VBA isn't my area of expertise. Sorry.

Resources