Capture sheet names and a particular cell value within a workbook

amaresh achar

Board Regular
Joined
Dec 9, 2016
Messages
108
Office Version
  1. 365
Platform
  1. Windows
Hi, I need a VBA / formula solution for one of my tasks:

I have multiple (Identical) worksheets in a workbook, and I need to plot a table with each sheet names and value of cell "B2" against each sheet name.

The table need to be created by adding new worksheet at the end.

Example:

Sheet1name Sheet2name Sheet3name Sheet4name Sheet5name Sheet6name Sheet7name SheetNname
"B2" of sheet1 "B2" of sheet2 "B2" of sheet3 "B2" of sheet4 "B2" of sheet5 "B2" of sheet6 "B2" of sheet7 "B2" of sheetN

Thanks in advance,
Amaresh
 

Attachments

  • sample.PNG
    sample.PNG
    42.1 KB · Views: 14

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Give this a try

VBA Code:
Sub SheetSummary()
  Dim i As Long
  
  Sheets.Add(After:=Sheets(Sheets.Count)).Name = "Values"
  For i = 1 To Sheets.Count - 1
    With Sheets(i)
      Sheets("Values").Cells(4, 2 + i).Resize(2).Value = Application.Transpose(Array(.Name, .Cells(2, 2).Value))
    End With
  Next i
  Sheets("Values").Range("B4:B5").Value = Application.Transpose(Array("Sheet Names", "Values in B2"))
End Sub
 
Upvote 0
You're welcome. Thanks for the follow-up. :)

BTW, I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
You're welcome. Thanks for the follow-up. :)

BTW, I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Yeah.. ok.. got it.. I have update my Office version and Platform details... Thanks for your suggestions..
 
Upvote 0
Hi, Peter_SSs,

Can you please modify the code to extract the values from G19 and I19 into one sheet.. (But this time i have the data in different xlsx files instead of sheets)

Thank you in advance,
Amaresh.A.R
 
Upvote 0
But this time i have the data in different xlsx files instead of sheets
How would we know which files to look in?

How would we know which sheet(s) in those files to look in G19 and I19?

What cells in what sheet in what file would the results go?
 
Upvote 0
Oh.. ? sorry.. I forgot to give those details..


1. I have attached an excel file "Extractor"..
2. when I run the macro from "value extractor", it should pop up file browser window to select the folder path of target Excel files..
3. and it should extract all the values from cell g19 and i19 from sheet 2 of every workbook in the folder and dump it in columnC & columnD respectively
4. and in columnB it should copy the workbook from which g19 & i19 cell values are copied.

Thanks in Advance,
Amaresh
 
Upvote 0
From what I can see this is not a simple adaptation of the earlier code but a separate question. Therefore I suggest that you start a new thread for it.
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,817
Members
449,049
Latest member
cybersurfer5000

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