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.

1 answer

  • Votes
  • Date
  • Descending date
  1. Moderator
    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. 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) ?
    2. 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.
    3. 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.