+ Reply to Thread
Results 1 to 17 of 17

Macros To name Worksheets

  1. #1
    Registered User
    Join Date
    12-13-2010
    Location
    Fiji
    MS-Off Ver
    Excel 2003
    Posts
    20

    Post Macros To name Worksheets

    Hi

    When exporting Excel worksheets into Workbooks via macros, my new workbooks are titled sheet1, sheet2 etc
    I would like my worksheets to be named based on the data displayed
    For example my excel report give data by student names
    It is grouped by student name hence the number of worksheet for each individual student
    So the first column give student name, second student Id etc etc
    Is there a way I can have my worksheet the same name as the data displayed in the first column

    I'm guessing it has something to do with cell range
    Last edited by cheiL; 07-18-2011 at 12:53 AM. Reason: Solved

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493

    Re: Macros To name Worksheets

    The first column meaning A1?
    Or do you want to loop through column A and create new sheets based on the the names in column A?
    Last edited by davesexcel; 07-13-2011 at 09:22 PM.

  3. #3
    Registered User
    Join Date
    12-13-2010
    Location
    Fiji
    MS-Off Ver
    Excel 2003
    Posts
    20

    Lightbulb Re: Macros To name Worksheets

    Quote Originally Posted by davesexcel View Post
    The first column meaning A1?
    Or do you want to loop through column A and create new sheets based on the the names in column A?
    I would like to loop through column A because while column A has only one name in it Column A's length is dependent on the number of rows in column B, so your second option sounds alot like what I am trying to do, is it possible

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493

    Re: Macros To name Worksheets

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!

  5. #5
    Registered User
    Join Date
    12-13-2010
    Location
    Fiji
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Macros To name Worksheets

    Quote Originally Posted by davesexcel View Post
    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!

    sample.xlsx

    see attchaed

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493

    Re: Macros To name Worksheets

    You don't have anything in column A

  7. #7
    Registered User
    Join Date
    12-13-2010
    Location
    Fiji
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Macros To name Worksheets

    Quote Originally Posted by davesexcel View Post
    You don't have anything in column A
    Hi there, I was for my example purposes to answer your question but yes my actual column is B

  8. #8
    Registered User
    Join Date
    12-13-2010
    Location
    Fiji
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Macros To name Worksheets

    Sorry meant "A" not I

  9. #9
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Macros To name Worksheets

    Hi cheil, I'm curious, in your first post you wanted to rename the sheets according to student names. In the workbook that you uploaded, you have sheets with hotel bookings and not student names, or anything to do with them.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  10. #10
    Registered User
    Join Date
    12-13-2010
    Location
    Fiji
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Macros To name Worksheets

    Quote Originally Posted by Mordred View Post
    Hi cheil, I'm curious, in your first post you wanted to rename the sheets according to student names. In the workbook that you uploaded, you have sheets with hotel bookings and not student names, or anything to do with them.
    Hi Mordred
    My first post was a scenario, after Dave asked for an illustration, it made more sense to just upload what i was working on rather going and recreating something, I just changed the values in some fields so that you don't see actual data
    I didn't mean to confuse everyone
    I really just want to know how to get the data provided in column B as the name of the worksheet and eventually name of the new workbook after running my macros.
    Would you guys be able to help me?

  11. #11
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493

    Re: Macros To name Worksheets

    Do you mean to rename a sheet in column B or rename a sheet in a specific cell in Column B?

  12. #12
    Registered User
    Join Date
    12-13-2010
    Location
    Fiji
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Macros To name Worksheets

    Quote Originally Posted by davesexcel View Post
    Do you mean to rename a sheet in column B or rename a sheet in a specific cell in Column B?
    my column b is how the data is grouped by hotel name, I want the data displayed in column be to be reflected as the name of the worksheet. for example worksheet 1 has has column b with hotel name as capricorn then worksheet 1 to be renamed to capricorn

  13. #13
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493

    Re: Macros To name Worksheets

    Not sure if this works on Merged cells but placing this code in the WORKBOOK Module may help
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    12-13-2010
    Location
    Fiji
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Macros To name Worksheets

    I tried to put this as a macro but it didn't work, should this go inside one of my already existing macros?
    I have two macros one for auto cells adjustment and then other for the exporting of the worksheets into individual workbooks

  15. #15
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,493

    Re: Macros To name Worksheets

    Did you see the part about workbook module?

  16. #16
    Registered User
    Join Date
    12-13-2010
    Location
    Fiji
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Macros To name Worksheets

    Quote Originally Posted by davesexcel View Post
    Did you see the part about workbook module?
    Yup, did that as well....it doesn't do anything, should I be calling this function somewhere within my macro or something? sorry just started using excel and macros still figuring out.
    this code appears as my module 2
    Last edited by cheiL; 07-17-2011 at 11:02 PM.

  17. #17
    Registered User
    Join Date
    12-13-2010
    Location
    Fiji
    MS-Off Ver
    Excel 2003
    Posts
    20

    Macros To name Worksheets

    Found it
    But if anybody can find me one that takes the entire contents of Column B instead of just cell 3, then please paste it
    Otherwise this will do for now


    Thanks


    Please Login or Register  to view this content.
    Last edited by cheiL; 07-18-2011 at 12:53 AM. Reason: Wrong place for putting word SOLVED

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1