Results 1 to 6 of 6

Thread: [RESOLVED] Creating index sheet with copied cells

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    3

    Resolved [RESOLVED] Creating index sheet with copied cells

    I have a spreadsheet with 50 worksheets all created from the same template. I want to create a front sheet that lists the names of the worksheets in column A and then in column B copy the data from G10 and then in column C copy the data from H10 from each of the worksheets.

    Currently I create a new worksheet and then use the following code:

    Code:
    Sub Sheetlister()
    
    Dim Sheet As Object
    Range("A2").Select
    For Each Sheet In ActiveWorkbook.Sheets
    ActiveCell.Formula = Sheet.Name
    ActiveCell.Offset(1, 0).Select
    Next Sheet
    
    End sub
    Can you help with adapting the code so that I can copy my data cells from each named sheet to the this sheet.

    Thank you

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Creating index sheet with copied cells

    Welcome to the forums

    something like this?

    vb Code:
    1. Sub PopulateData()
    2.     Dim i As Long, shtName As String, rowNo As Long
    3.    
    4.     '~~> Replace "Sheet1" below with the name of the sheet
    5.     '~~> where you want to display data
    6.     shtName = "Sheet1"
    7.     '~~> Row number from where you want to start putting data
    8.     rowNo = 1
    9.    
    10.     '~~> Loop thru the sheets in the workbook
    11.     For i = 1 To Sheets.Count
    12.         '~~> Checking if current sheet is not "Sheet1"
    13.         If Sheets(i).Name <> shtName Then
    14.             '~~> Get relevant values
    15.             Sheets(shtName).Range("A" & rowNo).Value = Sheets(i).Name
    16.             Sheets(shtName).Range("B" & rowNo).Value = Sheets(i).Range("G10").Value
    17.             Sheets(shtName).Range("C" & rowNo).Value = Sheets(i).Range("H10").Value
    18.             '~~> Increment row count
    19.             rowNo = rowNo + 1
    20.         End If
    21.     Next i
    22. End Sub
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    3

    Resolved Re: Creating index sheet with copied cells

    What a way to welcome me - a brilliant wave and a solution!!!!!!!

    Thank you so much, I had posted this on another forum and didn't get an answer that worked and I struggled to understand their code and I can work my way through yours and can now see how to adapt it for another worksheet I needed to do.

    Thanks again

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Creating index sheet with copied cells

    What a way to welcome me - a brilliant wave and a solution!!!!!!!
    You are welcome

    I had posted this on another forum and didn't get an answer that worked and I struggled to understand their code
    That is why VB Forums is the best

    Well, if your query is solved then do remember to mark this thread resolved. Check the link in my signature on how to mark a thread resolved
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  5. #5

    Thread Starter
    New Member
    Join Date
    Oct 2009
    Posts
    3

    Re: Creating index sheet with copied cells

    I had already - did you see the green tick, but I put it against my bit and not the thread sorry (Thinking I thought I had got it right, but I didn't!!)

  6. #6
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [RESOLVED] Creating index sheet with copied cells

    That's Ok
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width