Forum Discussion
Excel duplicate line meny at the same time and change the signs in a series of doublings.pervasive
- Aug 16, 2022
Run this macro:
Sub Dup() Dim r As Long Dim m As Long Application.ScreenUpdating = False m = Range("A" & Rows.Count).End(xlUp).Row For r = m To 1 Step -1 Range("A" & r).EntireRow.Copy Range("A" & r + 1).EntireRow.Insert Next r Application.CutCopyMode = False Application.ScreenUpdating = True End Sub
I found it c should be r
This works perfectly
Sub Opposite()
Const c = "G" ' column with data
Dim r As Long
Dim m As Long
Application.ScreenUpdating = False
m = Cells(Rows.Count, c).End(xlUp).Row
For r = 2 To m Step 2
Cells(r + 1, c).Value = -Cells(r, c).Value
Next r
Application.ScreenUpdating = True
End Sub
....
this code works for line 2 and column G, targeting doubling of all lines, no matter how long they are.
.for those who are looking at this, you need to read and change "A" to the appropriate column and (r) to the line where your data starts reading the comment above
thank you
Sorry about the mistake, I'll correct my reply.
- BjarkiwaageAug 16, 2022Copper Contributor
thank you,, thank you for the update on programming, it's been a long time since I've been there. and become more than forgetful.
there is no way i could have written this now but with your tip I was able to fix it
Regards Bjarki W