Consulting

Results 1 to 3 of 3

Thread: Format only the header data for all the sheets in workbook

  1. #1
    VBAX Mentor
    Joined
    Sep 2007
    Posts
    405
    Location

    Format only the header data for all the sheets in workbook

    Hi,

    I need to format only the headers (row 1 of used columns) of all the sheets in a file using macro. The column in each sheet differs. The formatting should be only for the used columns in the sheets.

    The coding which i have formats all the contents in the sheets to grey.

    -sindhuja

  2. #2
    Knowledge Base Approver VBAX Guru GTO's Avatar
    Joined
    Sep 2008
    Posts
    3,368
    Location
    Hi Sindhuja,

    Try recording the formatting on a blank/new sheet. Unless I am missing something, this would leave only finding the last column used

  3. #3
    VBAX Regular HaHoBe's Avatar
    Joined
    Aug 2004
    Location
    Hamburg
    Posts
    89
    Location
    Hi, sindhuja,

    UsedRangeRows(1) should only cover the columns used (and is independant of both start and end column). Example for Excel2007:

    [vba]Dim ws As Worksheet
    For Each ws In Worksheets
    With ws.UsedRange.Rows(1).Font
    .Name = "Arial"
    .Size = 12
    .Strikethrough = False
    .Superscript = False
    .Subscript = False
    .OutlineFont = False
    .Shadow = False
    .Underline = xlUnderlineStyleNone
    .ThemeColor = xlThemeColorLight1
    .TintAndShade = 0
    .ThemeFont = xlThemeFontNone
    .Bold = True
    End With
    Next ws[/vba] Ciao,
    Holger

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •