Looping through tabs and copying and pasting the data into one tab

alx1056

New Member
Joined
Jul 11, 2018
Messages
8
Hello,

I have an workbook with 44 tabs. Each tab is labeled with a number (1,2,3,4...). I want to be able to loop through each tab, copy the title of the tab and be able to paste the title beside the data in the tab. There are two columns in every tab. I want: Column A to have the title, Column B to have the original data and C to have the original data. How can I loop through this and copy and paste the header/title of the tab beside the already existing data?

I am new to excel so,
Any help is appreciated!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi & welcome to the board.
Is column A on those tabs blank?
 
Upvote 0
You said:
Each tab is labeled with a number (1,2,3,4...).

Do you mean each sheet is named 1,2,3,4...
We use the term name not label.
Or explain what a label is.

You said:
copy the title of the tab and be able to paste the title beside the data in the tab.

What is the title?
 
Upvote 0
If the answer to my question in post#2 is yes try
Code:
Sub AddShtName()
   Dim Ws As Worksheet
   For Each Ws In Worksheets
      Ws.Range("A1", Ws.Range("B" & Rows.Count).End(xlUp).Offset(, -1)).Value = Ws.name
   Next Ws
End Sub
Otherwise try
Code:
Sub AddShtName()
   Dim Ws As Worksheet
   For Each Ws In Worksheets
      Columns(1).Insert
      Ws.Range("A1", Ws.Range("B" & Rows.Count).End(xlUp).Offset(, -1)).Value = Ws.name
   Next Ws
End Sub
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,851
Messages
6,121,931
Members
449,056
Latest member
denissimo

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