VBA - Extract Cell H25 from every Sheet

Sunvisor

Board Regular
Joined
Oct 9, 2009
Messages
233
I have hundreds of sheets in a workbook.

I need to extract each of the sheets names and then each of the sheets value of cell H25 then paste them starting from A1-B1 all the way till the end.

Any suggestions!?
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Assuming that the workbook containing the data is the active workbook, the following macro displays the list in a newly created worksheet within the active workbook...

Code:
[FONT=Verdana][COLOR=darkblue]Option[/COLOR] [COLOR=darkblue]Explicit[/COLOR][/FONT]
 
[FONT=Verdana][COLOR=darkblue]Sub[/COLOR] test()[/FONT]
 
[FONT=Verdana]  [COLOR=darkblue]Dim[/COLOR] MyArray() [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Variant[/COLOR][/FONT]
[FONT=Verdana]  [COLOR=darkblue]Dim[/COLOR] wkbSource [COLOR=darkblue]As[/COLOR] Workbook[/FONT]
[FONT=Verdana]  [COLOR=darkblue]Dim[/COLOR] wksDest [COLOR=darkblue]As[/COLOR] Worksheet[/FONT]
[FONT=Verdana]  [COLOR=darkblue]Dim[/COLOR] wks [COLOR=darkblue]As[/COLOR] Worksheet[/FONT]
[FONT=Verdana]  [COLOR=darkblue]Dim[/COLOR] NumShts [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Long[/COLOR][/FONT]
[FONT=Verdana]  [COLOR=darkblue]Dim[/COLOR] Cnt [COLOR=darkblue]As[/COLOR] [COLOR=darkblue]Long[/COLOR][/FONT]
 
[FONT=Verdana]  [COLOR=darkblue]Set[/COLOR] wkbSource = ActiveWorkbook[/FONT]
 
[FONT=Verdana]  NumShts = wkbSource.Worksheets.Count[/FONT]
 
[FONT=Verdana]  [COLOR=darkblue]ReDim[/COLOR] MyArray(1 [COLOR=darkblue]To[/COLOR] NumShts, 1 [COLOR=darkblue]To[/COLOR] 2)[/FONT]
 
[FONT=Verdana]  [COLOR=darkblue]For[/COLOR] [COLOR=darkblue]Each[/COLOR] wks [COLOR=darkblue]In[/COLOR] wkbSource.Worksheets[/FONT]
[FONT=Verdana]      Cnt = Cnt + 1[/FONT]
[FONT=Verdana]      MyArray(Cnt, 1) = wks.Name[/FONT]
[FONT=Verdana]      MyArray(Cnt, 2) = wks.Range("H25").Value[/FONT]
[FONT=Verdana]  [COLOR=darkblue]Next[/COLOR] wks[/FONT]
 
[FONT=Verdana]  [COLOR=darkblue]Set[/COLOR] wksDest = wkbSource.Worksheets.Add[/FONT]
 
[FONT=Verdana]  wksDest.Range("A1").Resize(UBound(MyArray, 1), UBound(MyArray, 2)).Value = MyArray[/FONT]
 
[FONT=Verdana][COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR][/FONT]
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,716
Members
452,939
Latest member
WCrawford

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