VBA or Formula to create Master Sheet

Status
Not open for further replies.

Excel1991

Board Regular
Joined
Aug 1, 2018
Messages
58
Hello,

I have a workbook with 120 tabs. Each tab has a different different name, but each tab has values in cells w12, x12, y12, z12, aa12 that i would like to get.

Essentially I am trying to create a summary sheet that has the sheet names in column A and then the corresponding values. it would look like this

[TABLE="width: 500"]
<tbody>[TR]
[TD]SHEET NAME[/TD]
[TD]10TH%[/TD]
[TD]25TH%[/TD]
[TD]Median[/TD]
[TD]75th%[/TD]
[TD]90th%[/TD]
[/TR]
[TR]
[TD]cardiology[/TD]
[TD]cell w12[/TD]
[TD]cell x12[/TD]
[TD]celly12[/TD]
[TD]cell z12[/TD]
[TD]cell aa12[/TD]
[/TR]
[TR]
[TD]dermatology[/TD]
[TD]cell w12[/TD]
[TD]cell x12[/TD]
[TD]cell y12[/TD]
[TD]cell z12[/TD]
[TD]cell aa12[/TD]
[/TR]
[TR]
[TD]emergency medicine[/TD]
[TD]cell w12[/TD]
[TD]cell x12[/TD]
[TD]cell y12[/TD]
[TD]cell z12[/TD]
[TD]cell aa12[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


I was hoping there was a way to use VBA to first list out all of the sheet names in column A and then go to each sheet and pull the values in cells w12, x12, y12, z12, and aa12. Is this possible? Thanks!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Does the summary sheet already exist, or does it need to be created?
If it exists, does it already have any data? & should that be over-written?
 
Upvote 0
Ok, how about
Code:
Sub Excel1991()
    Dim ws As Worksheet
    Dim i As Long
    i = 1
    With Sheets("Mastersheet")
        .Range("A1:F1").Value = Array("Sheet name", "10th%", "25th%", "Median", "75%", "90th%")
        For Each ws In Worksheets
            If ws.Name <> .Name Then
                i = i + 1
                .Cells(i, 1).Value = ws.Name
                .Range("B" & i).Resize(, 5).Value = ws.Range("W12:AA12").Value
            End If
        Next ws
    End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0
You're welcome & thanks for the feedback

Ok, how about
Code:
Sub Excel1991()
    Dim ws As Worksheet
    Dim i As Long
    i = 1
    With Sheets("Mastersheet")
        .Range("A1:F1").Value = Array("Sheet name", "10th%", "25th%", "Median", "75%", "90th%")
        For Each ws In Worksheets
            If ws.Name <> .Name Then
                i = i + 1
                .Cells(i, 1).Value = ws.Name
                .Range("B" & i).Resize(, 5).Value = ws.Range("W12:AA12").Value
            End If
        Next ws
    End With
End Sub
Hello,

I used this code, and updated all the ranges for my own situation, but it is only returning the values for the first row in my data range on each sheet. My data range is "J9:P9" and has varying amounts of rows for each sheet. Any advice on how to modify this for my needs?

Thanks so much!
 
Upvote 0
Duplicate to: VBA loop to collect data from all sheets

In future, please do not post the same question multiple times. Per Forum Rules (#12), posts of a duplicate nature will be locked or deleted.

In relation to your question here, I have closed this thread so please continue in the linked thread.
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,885
Messages
6,175,181
Members
452,615
Latest member
bogeys2birdies

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