Posted By

lolrenx on 12/20/12


Tagged

header format excel vba range


Versions (?)

Format Header Range


 / Published in: Visual Basic
 

quick way to get column headers formatted

  1. Public Sub Format_Headers(tgtRange As Range, Optional NoFill As Boolean, _
  2. Optional ForceVertical As Boolean, Optional NoBold As Boolean)
  3.  
  4. If tgtRange Is Nothing Then _
  5. Exit Sub
  6.  
  7. With tgtRange
  8. .Interior.Pattern = xlSolid
  9. .Interior.ThemeColor = xlThemeColorDark1
  10. If Not NoFill Then .Interior.ColorIndex = 15
  11. If Not NoBold Then .Font.Bold = True Else .Font.Bold = False
  12. .Borders(xlDiagonalDown).LineStyle = xlNone
  13. .Borders(xlDiagonalUp).LineStyle = xlNone
  14. .Borders.LineStyle = xlContinuous
  15. If Not NoBold Then .Borders.Weight = xlMedium Else .Borders.Weight = xlThin
  16. If Not ForceVertical Then .Borders(xlInsideVertical).LineStyle = xlNone
  17. End With
  18.  
  19. End Sub

Report this snippet  

You need to login to post a comment.