I created a macro that is not working properly. When I created it, I had data that utilized rows all the way down to 1501 in columns "J" and "K". Not all my files ae the same. So When I use the created macro, It still builds to row 1501 no matter what. I know there is a way to tell it to go to the end of that data, But when I edit it to do so, it errors out.
Here is the portion of the macro where it is going to row 1501:
Cells.Select
Cells.EntireColumn.AutoFit
Columns("J:K").Select
Selection.Delete Shift:=xlToLeft
Range("J2").Select
ActiveCell.FormulaR1C1 = "700"
Range("K2").Select
ActiveCell.FormulaR1C1 = "2330"
Range("J2:K2").Select
Selection.AutoFill Destination:=Range("J2:K1501")
Range("J2:K1501").Select
Columns("U:U").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("U2").Select
ActiveCell.FormulaR1C1 = "=RIGHT(RC[-2]+100,2)"
Range("U2").Select
Selection.AutoFill Destination:=Range("U2:U1501")
Range("U2:U1501").Select
Selection.Copy
Range("S2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("T2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Columns("U:U").Select
Selection.Delete Shift:=xlToLeft
ActiveWindow.ScrollColumn = 2
Here is the portion of the macro where it is going to row 1501:
Cells.Select
Cells.EntireColumn.AutoFit
Columns("J:K").Select
Selection.Delete Shift:=xlToLeft
Range("J2").Select
ActiveCell.FormulaR1C1 = "700"
Range("K2").Select
ActiveCell.FormulaR1C1 = "2330"
Range("J2:K2").Select
Selection.AutoFill Destination:=Range("J2:K1501")
Range("J2:K1501").Select
Columns("U:U").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("U2").Select
ActiveCell.FormulaR1C1 = "=RIGHT(RC[-2]+100,2)"
Range("U2").Select
Selection.AutoFill Destination:=Range("U2:U1501")
Range("U2:U1501").Select
Selection.Copy
Range("S2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("T2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Columns("U:U").Select
Selection.Delete Shift:=xlToLeft
ActiveWindow.ScrollColumn = 2