Hello, i have been scouring the forums for a solution on this but cannot find anything that answers my question, althought there is hundreds of threads on the excel UDF I am creating an excel sheet within autoit (hidden) and then i want to run the following macro on the sheet: Sub insertlines() Dim i As Long: i = 1 Do Until Cells(i, 1) = "" If Cells(i, 2).Value <> Cells(i + 1, 2).Value Then Range(Cells(i, 1), Cells(i, 16)).Borders(xlEdgeBottom).LineStyle = xlContinuous End