VBA: Copy Paste Values Based on a Condition
-
Hello,
I would like to set up a macro that allows me to copy a column and paste it as values exactly in the same place, so as not to lose my data.
The condition is to copy/paste only the column where the date is equal to the current date.
After numerous tests, your insight would greatly help me in my progress.
Thank you in advance.
I would like to set up a macro that allows me to copy a column and paste it as values exactly in the same place, so as not to lose my data.
The condition is to copy/paste only the column where the date is equal to the current date.
After numerous tests, your insight would greatly help me in my progress.
Thank you in advance.
1 answer
-
ModeratorHello,
If you're struggling with the copy-paste value, you can simply start a macro recording and do it manually.
You can then adapt it in your code.-
-
Moderator@marmotte0583https://www.excel-pratique.com/fr/vba.php
Take an interest in the lessons on sheets and cells, and conditions (on the right) -
-
Moderator@marmotte0583To search for the value in a cell:
Cells(x,y).Value
, with x and y respectively the row and column (as numbers)
Variable storing "today":date
Structure of an "if" condition:If Condition 1 to be verified Then
Code to execute if condition 1 is verified
Elseif Condition 2 to be verified Then
Code to execute if condition 2 is verified
[...]
Else
Code to execute in all other cases
End if
"Elseif" and "Else" are not mandatory.
-