Create a MACRO

philb99

Active Member
Joined
Feb 3, 2014
Messages
426
Office Version
  1. 2013
Platform
  1. 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?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
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
 
Upvote 0
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?
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,224,735
Messages
6,180,635
Members
452,991
Latest member
JM_000888

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top