Create a MACRO

philb99

Active Member
Joined
Feb 3, 2014
Messages
316
Office Version
2010
Platform
Windows
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?
 

Some videos you may like

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

theBardd

Rules violation
Joined
Jan 21, 2012
Messages
912
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
 

philb99

Active Member
Joined
Feb 3, 2014
Messages
316
Office Version
2010
Platform
Windows
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?
 

theBardd

Rules violation
Joined
Jan 21, 2012
Messages
912
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.
 

philb99

Active Member
Joined
Feb 3, 2014
Messages
316
Office Version
2010
Platform
Windows
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
 

theBardd

Rules violation
Joined
Jan 21, 2012
Messages
912
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,101,774
Messages
5,482,837
Members
407,365
Latest member
Leah Ashley

This Week's Hot Topics

  • Finding issue in If elseif else with For each Loop
    Finding issue in If elseif else with For each Loop I have tried this below code but i'm getting in Y column filled with W005. Colud you please...
  • MsgBox Error
    Hi Guys, I have the below error show up when i try and run my macro in File1 but works fine if i copy and paste the same code into file2. [ATTACH...
  • CELL FORMAT - IF CONDITION
    My Cell Format is [B]""0.00" Cr". [/B]But in the cell, it is showing 123.00 for editing. (123 is entry figure). (Data imported from other...
  • Show numbers nearly the same
    Is this possible. I have a number that can change very time eg 0.00001234 Then I have a lot of numbers 0.0000001, 0.0000002, 0.00000004...
  • Please i need your help to create formula
    I need a formula in cell B8 to do this >>if b1=1 then multiply ( cell b8) by 10% ,if b1=2 multiply by 20%,if=3 multiply by 30%. Thank you in...
  • Got error while adding column and filter
    Got error while adding column and filter In column Z has some like "Success" and "Error". I want to add column in AA if the Z cell value is...
Top