I am using a macro to add formatting to a selected range of cells. (Excel 2007) The number of columns and rows of the selected range are always different. Also the selected areas are not always on the same worksheet.
I recorded a macro and made some minor changes to the code, but I was unable to figure out how I could apply formatting to the cells of the penultimate row of the selected range, which would be in this case double underline borders.
Sub feladat()
Application.ScreenUpdating = False
Application.CutCopyMode = False
With Selection
.HorizontalAlignment = xlCenter
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeTop)
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeRight)
.Weight = xlMedium
End With
With Selection.Borders(xlInsideVertical)
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.Weight = xlThin
End With
Selection.SpecialCells(xlCellTypeFormulas, 23).Select
Selection.Font.Bold = True
Application.ScreenUpdating = True
End Sub
I've tried finding the penultimate row using offset, but with no luck since after running the macro the active cell is always located at a different place.