'How to copy and paste entire column conditionally using VBA

I'm trying to copy and paste columns automatically that fit a certain criteria. My code currently analyzes the condition correctly, but I haven't been able to get it to copy / paste the corresponding column. Essentially what I'm trying to achieve is - if row #1 contains today's date - copy and paste the entire column as a value to get rid of the formulas. I currently have the code below:

Dim K As String
  K = Date
  MsgBox K

Dim i As Integer

For i = 1 To 9
    If (Cells(1, i).Value = K) Then Cells(1, i).EntireColumn.Copy
    Cells(1, i).PasteSpecial
    
Next i

End Sub


Solution 1:[1]

Got it!

Dim K As String
  K = Date
  MsgBox K

Dim i As Integer

For i = 1 To 9
    If (Cells(1, i).Value < K) Then Cells(1, i).EntireColumn.Copy
    Cells(1, i).PasteSpecial Paste:=xlPasteValues
Next i

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MrTheBard