Forum Discussion

Lindsy's avatar
Lindsy
Copper Contributor
Sep 13, 2022
Solved

VBA to move cell values to a cell address in each row of a table

Hi, I have a list on sheet "New Template" of values in range L9:L32 (New Date) with cell addresses (eg, $D$14) in the next column range M9:M32 (Cell Ref) that I need the values coping to on a sheet ...
  • HansVogelaar's avatar
    HansVogelaar
    Sep 13, 2022

    Lindsy 

    Thanks. The cause of the problem was that there are other data below the update table.

    This version should work:

    Sub MoveDates()
        Dim ws As Worksheet
        Dim wt As Worksheet
        Dim s As Long
        Dim m As Long
        Application.ScreenUpdating = False
        Set ws = Worksheets("New Template")
        Set wt = Worksheets("Dates")
        m = ws.Range("L31").End(xlUp).Row
        For s = 9 To m
            wt.Range(ws.Range("M" & s).Value).Value = ws.Range("L" & s).Value
        Next s
        ws.Range("L9:L" & m).ClearContents
        Application.ScreenUpdating = True
    End Sub

Resources