PDA

View Full Version : [SOLVED:] VBA - Copy Paste data to another sheet based on criteria



HY_C
06-23-2022, 10:42 PM
All the data is in sheet 1, I want to compare the value at column C and D. If the value at column C is less than or equal to column D, copy the value in column B, E and F to sheet 2. The data will be paste special (only value) and to the desired columns shown below. The code will continue until there is no data left in sheet 1 column B.

If criteria is meet (value at column C <= Column D) :
Sheet 1 Sheet 2
Copy data at column B -> Paste at Column C
Copy data at column E -> Paste at Column B
Copy data at column F -> Paste at Column D

There will be a button in sheet 1, when the button is pressed, all the existing data in the table (sheet 2) will be deleted before pasting a new one.

Please help! Thank you!

29875

arnelgp
06-24-2022, 04:18 AM
try this

p45cal
06-24-2022, 09:47 AM
…and a Power Query offering attached.

HY_C
06-27-2022, 03:26 AM
Thank you so much arnelgp and p45cal! :bow: