Hello!
I have two ranges, [H23:I32] and [J23:K50].
I need to copy values from [H23:I32] to [J23:K50] if [J23:K50] is empty, and if [J23:K50] is not empty I need to find the last row and add [H23:I32] below.
It's a growing list of values.
The "copy if empty" works, but the "add to the end of the list" doesn't unfortunately. It does something, but clearly not the thing I need.
Instead of copying H23-I23 to J:K row by row my code starts wiping data J23 > K23 > J24 > K24 one cell at a time instead of copying [H:I] to the end of [J:K]
Any suggestions how to fix this?
I have two ranges, [H23:I32] and [J23:K50].
I need to copy values from [H23:I32] to [J23:K50] if [J23:K50] is empty, and if [J23:K50] is not empty I need to find the last row and add [H23:I32] below.
It's a growing list of values.
The "copy if empty" works, but the "add to the end of the list" doesn't unfortunately. It does something, but clearly not the thing I need.
Instead of copying H23-I23 to J:K row by row my code starts wiping data J23 > K23 > J24 > K24 one cell at a time instead of copying [H:I] to the end of [J:K]
VBA Code:
Sub Total_Loop()
Application.ScreenUpdating = False
Dim c As Range
For Each c In Range("J23:K50" & Cells(Rows.Count, "J").End(xlUp).Row)
If c.Value <> "" Then
Range("J23:K50" & Cells(Rows.Count, "J").End(xlUp).Row + 1) = Range("H23:I32")
Else: c.Value = c.Offset(, -2).Value
End If
Next
Application.ScreenUpdating = True
End Sub
Any suggestions how to fix this?