I have some VBA code in a macro that was working fine in Excel 2016 with update 1703. However, one user just had the new update (1705) and now this macro gives a "1004 application/object unknown" error. The error happens in this section of code, specifically at the second Selection.Offset(1,0).Select line.
'Get the values from the first column
Range("A2 : A" & NumRows).Select
Selection.Copy
'Paste the copy once for each column containing data
For I = 2 To NumCols
Range("A2").Select
Selection.End(xlDown).Select
Selection.Offset(1, 0).Select
ActiveSheet.Paste
Next
'Insert a new column at the front of the worksheet
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
'Get the first data column header and copy it
Range("C1").Select
Selection.Copy
'Paste the selection into the first column
Range("A2:A" & NumRows).Select
ActiveSheet.Paste
'Get and copy the rest of the headers
For I = 1 To NumCols
Range("C1").Select
Selection.Offset(0, I).Select
Selection.Copy
For C = 2 To NumRows
Range("A2").Select
Selection.End(xlDown).Select
Selection.Offset(1, 0).Select
ActiveSheet.Paste
Next
Next
One thing I noticed between computers with 1703 and 1705 is that on 1703 the new column inserted is empty, and with 1705 the new column has values all the way to the maximum number of rows (the row number is > 1 million).
So I guess my question is, how can I insert the new column without the data filling up all rows until the Excel maximum row?