I am trying to run a macro. The macro looks in each row in column A and if the value is greater than 0 it will copy a range of cells from the same row (M:BT) and paste and transpose that range in the cell in column K of the same row. The code below works but the number of rows change and can be a lot. I need it to loop through until no more data can be found in column A. Keep in mind there will be empty rows. As I said before my code works with a small sample 100 rows but when I did one for like 65,000 rows it give me an
Overflow error
Any ideas how to fix this?
Sub Macro1()
'
' Macro1 Macro
'
' Keyboard Shortcut: Ctrl+w
'
Range("K1").Select
ActiveCell.FormulaR1C1 = "DATE"
Range("L1").Select
ActiveCell.FormulaR1C1 = "DAYS"
Columns("BU:EB").Select
Selection.Delete Shift:=xlToLeft
Columns("EC:IR").Select
Selection.Delete Shift:=xlToLeft
With ActiveSheet
lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
Dim AddRows As Integer: AddRows = 59
Dim i As Integer: i = lastrow
Do While i <> 1
Rows(i & ":" & i + AddRows - 1).Insert
i = i - 1
Loop
ScreenUpdating = True
Rows("2:60").Select
Selection.Delete Shift:=xlUp
Range("A1").Select
Dim x As Integer, a As Integer
a = Cells(Rows.Count, 1).End(xlUp).Row
For x = 2 To a
If Cells(i, 1) > 0 Then
Range(Cells(x, 13), Cells(x, 72)).Select
Selection.Copy
Cells(x, 11).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=True, Transpose:=True
End If
Next x
End Sub