I am trying to have a border drawn around a group of cells. This group of cells changes per list I make, but only the height changes. The width is always the same (from column A to column J) and the top is always at row 5. Only the last row changes. How can a border be drawn around this group of cells no matter the size of the group of cells? Below is the macro I have written so far.
Cells.Select Cells.EntireColumn.AutoFit ActiveWindow.SmallScroll ToRight:=7 Columns("K:N").Select Selection.ClearContents ActiveWindow.SmallScroll ToRight:=-7 Range("A2").Select Rows("2:2").RowHeight = 49.5 lastrow1 = Range("A65536").End(xlUp).Select Range("A5:J" & lastrow1).BorderAround.Weight = xlThin lastrow2 = Cells(Cells.Rows.Count, "C").End(xlUp).Row For I = lastrow2 To 2 Step -1 If Cells(I, "C").Value <> Cells(I - 1, "C").Value Then Rows(I).Insert Next I With ActiveSheet.PageSetup .Orientation = xlLandscape .PaperSize = xlPaperA4 .FirstPageNumber = xlAutomatic .FitToPagesWide = 1 .FitToPagesTall = 1 .PrintErrors = xlPrintErrorsDisplayed End With End Sub
This line of code does not work
and I can't come up with an answer that does work.
Any help is much appreciated!