Search code examples
vbaexcelcopy-paste

Excel VBA - Copy Paste Range in column if Date matches


My macro is used to copy/paste live data to overwrite an old budget.

Essentially I want to do the following:

If the date in T6 = date in Range(G6:R6) then copy Range(T10:T30) to Range(?10:?30), where ? is the column of the cell that matched the date.


Solution

  • This should match what you're asking for. In the future, you should share the code that you've attempted so far.

    Dim cell As Range
    For Each cell In Range("G6:R6")
        If cell.value = Range("T6").value Then
            Range(Cells(10, cell.Column), Cells(30, cell.Column)).value = Range("T10:T30").value
        End If
    Next cell