Amateur hour
New Member
- Joined
- Aug 21, 2017
- Messages
- 5
Hi all,
First off, I'm not a programmer, I just Mr Magoo my way through this stuff, copying and modifying stuff I find online. I hate to be the guy that signs up just to ask a question but after a day of searching and messing around, I'm still lost. So, thanks in advance!!
I have a macro that takes a set of numbers in columns A:J and lines them up in the A column, in order. After Row 1, (9) blank rows are inserted then B1:J1 are copied and transposed to A2:A10. Then the loop runs again, inserting (9) blank rows again under row 11. Everything works dandy in Excel 2013.
In Excel 2016, the loop runs as intended the first time. Then when the loop runs the 2nd time, the values that were copied in the first loop (B1:J1) are inserted as a new row instead of inserting the (9) new blank rows.
This is the problem line:
And the macro:
First off, I'm not a programmer, I just Mr Magoo my way through this stuff, copying and modifying stuff I find online. I hate to be the guy that signs up just to ask a question but after a day of searching and messing around, I'm still lost. So, thanks in advance!!
I have a macro that takes a set of numbers in columns A:J and lines them up in the A column, in order. After Row 1, (9) blank rows are inserted then B1:J1 are copied and transposed to A2:A10. Then the loop runs again, inserting (9) blank rows again under row 11. Everything works dandy in Excel 2013.
In Excel 2016, the loop runs as intended the first time. Then when the loop runs the 2nd time, the values that were copied in the first loop (B1:J1) are inserted as a new row instead of inserting the (9) new blank rows.
This is the problem line:
Code:
Row(iRow + 1 & ":" & iRow + 9).EntireRow.Insert
And the macro:
Code:
Dim rng As Range
Dim iRow As Integer
Dim lastCell As Integer
Dim LCx9 As Integer
Dim lastRow As Long
Range("A1").Select
Set rng = ActiveCell.CurrentRegion
lastCell = rng.Columns(1).Rows.Count + 1
LCx9 = (lastCell * 9) + lastCell
For iRow = 1 To LCx9
Row(iRow + 1 & ":" & iRow + 9).EntireRow.Insert
Range(Cells(iRow, 2), Cells(iRow, 10)).copy
Range(Cells(iRow + 1, 1), Cells(iRow + 9, 1)).PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
iRow = iRow + 9
Next iRow