Reputation: 163
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
Upvotes: 1
Views: 890
Reputation: 163
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
Upvotes: 1