I'm really new to VBA and trying to figure out how to create a loop so that, when the value in column A is “1”, the values from columns E to N in the row immediately below are copied to the row above (without inserting a new row, just pasting over the existing values). I've been through the course book and dozens of Excel forums and can't see a way of doing this? Is it possible?
Thanks, Adam
Something like this should work
Sub test()
Dim n as Integer
Dim i As Integer
n = 100
For i = 1 To n
If CInt(Range("a" & i)) = 1 Then
Range("e" & i + 1 & ":n" & i + 1).Copy
Range("e" & i).PasteSpecial xlPasteValues
End If
Next i
Application.CutCopyMode = False
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.