Forum Discussion
Lindsy
Sep 13, 2022Copper Contributor
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 ...
- Sep 13, 2022
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
Lindsy
Sep 13, 2022Copper Contributor
Hi, I have sent you a private message. Thank you so much!!
HansVogelaar
Sep 13, 2022MVP
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- LindsySep 13, 2022Copper ContributorAnd the last error is my address formula. Thank you so much for your help, that's amazing!!!