1. You should not Select things to just act on them. That's just Macro Recorder code; you need to really clean it up and possibly generalize it
All the lines that are similar to ...
Range("A3").Select ActiveCell.FormulaR1C1 = "Line Number"
... could be written more efficiently and concisely as ...
2. All that code in 3-4 posts could be more useful to reviewer if it were in a workbook with sample data inputs and a sample of the desired outputRange("A3").Value = "Line Number"