Results 1 to 6 of 6

Thread: Create a MACRO
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Feb 2014
    Posts
    295
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Create a MACRO

    Looking for help writing a MACRO to undertake the following.

    I have a spreadsheet with multiple tabs x 11 - these tabs have team names, for example North, South, West, East.

    My existing MACRO transfers all of the tabs to a Summary tab at the end. However I have found that when I do this I don't have the easy ability to identify my teams correctly - all other analysis is perfect.

    What I would like to try and do before running my existing MACRO is enter a new column A, call it "Team" and then enter in each row below the name of the team, ie what the tab is called, then run my MACRO to move to a new Summary tab

    Is this possible please?

  2. #2
    Rules violation
    Join Date
    Jan 2012
    Posts
    912
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Create a MACRO

    Off the top

    Code:
    For Each ws In Activworkbook.Worksheets
    
        ws.Columns(1).Insert
        ws.Range("A1").Value="Team"
        ws.Range("A2").Resize(ws.Cells(ws.Rows.Count,"B").End(xlUp).Row).Value = ws.Name
    Next ws

  3. #3
    Board Regular
    Join Date
    Feb 2014
    Posts
    295
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Create a MACRO

    Hi - thanks for your help on this but nothing appears to be working, I am getting error prompt - Compile Error - Invalid Outside Procedure.

    Do I need something else?

  4. #4
    Rules violation
    Join Date
    Jan 2012
    Posts
    912
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Create a MACRO

    You have to put the code in a sub in a module and run the sub, that is basic VBA.

    BTW, I mis-spelt ActiveWorkbook in my original reply.

  5. #5
    Board Regular
    Join Date
    Feb 2014
    Posts
    295
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Create a MACRO

    Thanks - sorry I meant to say that I am not an expert on MACRO design, I have received some great help from this forum. You have to put it in a Sub means I might need to type something like
    Sub EnterTeamName () at the top maybe

  6. #6
    Rules violation
    Join Date
    Jan 2012
    Posts
    912
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Create a MACRO

    Yes, and add End Sub at the end, and find some way of launching it, such as a button on a worksheet, or just run it directly from Excel.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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