Workbooks in a folder and list the worksheets

  • Dear All,


    By using Excel spreadsheet(VBA), i need help to get a list of workbooks in a folder and list the worksheet names underneath. Any ideas?

    e.g.

    Workbook 1
    Worksheet 1
    Worksheet 2
    Worksheet 3


    Workbook 2
    Worksheet 1
    Worksheet 2
    .....


    Thanks!!!!

  • Re: Workbooks in a folder and list the worksheets


    Hi Mech


    Welcome to ozgrid. Give the following a try. Change the path to suit and don't forget to include the backslash.


    Take care


    Smallman


  • Re: Workbooks in a folder and list the worksheets


    Thanks for quick reply!!


    Where should i put this code in Excel and how to run it?

  • Re: Workbooks in a folder and list the worksheets


    Open the VB Editor (Alt + F11)
    Menu > Insert > Module (not class module)


    Copy and paste the code into the VB Editor
    Adjust the code for the correct file path


    Close the VB Editor (Alt + Q)


    Invoke the Macro Dialog to run the code (Alt + F8)

  • Re: Workbooks in a folder and list the worksheets


    Hi Ingo


    If your lines to do what you requested look like the below you are on the right track. Included before the For Statement.


    Code
    twbk.Sheets("Sheet1").Range("A65536").End(xlUp)(2).Font.Color = vbBlue
        twbk.Sheets("Sheet1").Range("A65536").End(xlUp)(2).Font.Bold = True


    Take care


    Smallman

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!