Consulting

Results 1 to 10 of 10

Thread: macro to remove headers in a multiple sheet spreadsheet

  1. #1
    VBAX Regular
    Joined
    Aug 2008
    Posts
    11
    Location

    macro to remove headers in a multiple sheet spreadsheet

    Hi,

    does anyone have an excel macro which can remove headers (first rows) in a multiple sheet spreadsheet?

    I'd appreciate it very much if you could pass it on. Even if it is a macro that does something similar.

    thanks for your assistance.

    cheers

  2. #2
    VBAX Contributor
    Joined
    May 2008
    Location
    bangalore
    Posts
    199
    Location
    u can try some thing like this

    Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
    Sheets("Sheet1").Activate
    Range("A1").Select
    Selection.EntireRow.Delete

  3. #3
    VBAX Regular
    Joined
    Aug 2008
    Posts
    11
    Location
    Hi, thanks for the help but, i get the msg below when i run it.


    "invalid outside procedure".

  4. #4
    VBAX Contributor
    Joined
    May 2008
    Location
    bangalore
    Posts
    199
    Location
    do check with the sheets names...
    else
    create a new module

    Sub del()
    Worksheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
    Sheets("Sheet1").Activate
    'Cells.Select
    Selection.ClearContents
    End Sub

  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]Option Explicit
    Sub ClearHeaders()
    Dim sh As Worksheet
    For Each sh In Sheets
    sh.Rows(1).ClearContents
    Next
    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  6. #6
    VBAX Regular
    Joined
    Aug 2008
    Posts
    11
    Location
    ok, we are making progress!
    but on the line of code in bold, how can i include the other sheets?
    it did work on the "Unreleased" one but the others still have the header.
    it must be something very simple...

    Sub del()
    Sheets(Array("Unreleased", "Pending Inspection", "Inspected - Skipped", "Inspected - Complete")).Select
    Sheets("Unreleased").Activate
    Range("A1").Select
    Selection.EntireRow.Delete
    End Sub


    thanks for your help!

  7. #7
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    I would only use the array method if it applies to specific sheets, not all sheets., otherwise see post 5
    [vba]Sub del()
    Sheets(Array("Unreleased", "Pending Inspection", "Inspected - Skipped", "Inspected - Complete")).Select
    Rows(1).Select
    Selection.ClearContents
    Sheets(1).Select
    Range("A1").Select
    End Sub
    [/vba]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  8. #8
    VBAX Contributor
    Joined
    May 2008
    Location
    bangalore
    Posts
    199
    Location
    small advice

    insted of
    Selection.EntireRow.Deleteuse this
    Selection.ClearContents

    As its in arrry it will clear header in respected sheet ,but u neeed to mention sheet anemas correctly

  9. #9
    VBAX Regular
    Joined
    Aug 2008
    Posts
    11
    Location
    Hi all,
    thanks for the help.
    i got it to work.
    thanks mdmackillop vbmenu_register("postmenu_157236", true);
    i used post #5 which is what i was looking for.

    Shamsam1 thanks for the help, i will keep this array idea for another macro i also need.

    thank you

  10. #10
    VBAX Contributor
    Joined
    May 2008
    Location
    bangalore
    Posts
    199
    Location
    do mark ur thread as solved......

Posting Permissions

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