VBA: Copy Paste Values Based on a Condition

marmotte0583 Posted messages 3 Status Member -  
Arkana0 Posted messages 1980 Registration date   Status Moderator Last intervention   -
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.

1 answer

  1. Arkana0 Posted messages 1980 Registration date   Status Moderator Last intervention   183
     
    Hello,

    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.
    1
    1. marmotte0583 Posted messages 3 Status Member
       
      Je te remercie pour ta rapidité de réponse, comme tu me l'as dit j'ai fait la manip manuellement, peux-tu m'indiquer maintenant comment je dois faire pour ajouter ma condition (faire le copier/coller que si la date de la colonne est égale à la date courante) ?
      0
      1. Arkana0 Posted messages 1980 Registration date   Status Moderator Last intervention   183 > marmotte0583 Posted messages 3 Status Member
         
        https://www.excel-pratique.com/fr/vba.php

        Take an interest in the lessons on sheets and cells, and conditions (on the right)
        0
    2. marmotte0583 Posted messages 3 Status Member
       
      I looked for a long time before posting my question on this forum, but being a beginner in VBA, I absolutely do not understand the explanations in the lessons, at least I cannot adapt them to my problem.
      0
      1. Arkana0 Posted messages 1980 Registration date   Status Moderator Last intervention   183 > marmotte0583 Posted messages 3 Status Member
         
        To 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.
        0