+ Reply to Thread
Results 1 to 5 of 5

Add column A for all sheets

Hybrid View

  1. #1
    Registered User
    Join Date
    06-26-2013
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2003, 07, 10
    Posts
    92

    Add column A for all sheets

    Hi I need to add a new column at column A in all sheets. I have this code to implement it into one sheet but not all of them. Can anyone help me on how to make this macro add column A for every sheet?

    Formula: copy to clipboard

    Sub addColumnA()
    '
    ' addColumnA Macro
    'Adds column "A" to a spreadsheet
    '
    Columns("A:A").Select
    Selection.Insert Shift:=xlToRight
    End Sub

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Add column A for all sheets

    Sub inseertc()
    Dim ws As Worksheet
    Application.ScreenUpdating = 0
    For Each ws In ThisWorkbook.Worksheets
        ws.Columns(1).Insert
    Next
    Application.ScreenUpdating = True
    End Sub

  3. #3
    Registered User
    Join Date
    06-26-2013
    Location
    Northern Ireland
    MS-Off Ver
    Excel 2003, 07, 10
    Posts
    92

    Re: Add column A for all sheets

    Thanks AB33. I also find this works too.

    Formula: copy to clipboard

    Sub addColumnA()

    Dim ws As Worksheet

    For Each ws In ActiveWorkbook.Worksheets

    ws.[A:A].Insert

    Next ws

    Call removeGridlines
    End Sub

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Add column A for all sheets

     ws.[A:A].Insert is the same as columns(1), or columns("A")

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,619

    Re: Add column A for all sheets

    This is Select/Selection comes in play.
    Sub test()
        Sheets.Select
        Sheets(1).Activate
        Columns(1).Select
        Selection.Insert
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1