Consulting

Results 1 to 4 of 4

Thread: Need help naming a worksheet based off another worksheet in VBA

  1. #1
    VBAX Newbie
    Joined
    Jun 2015
    Posts
    2
    Location

    Need help naming a worksheet based off another worksheet in VBA

    Right now I have two sheets, named Sept 2014 Raw Data and Sept 2013 Raw Data. I am taking the raw data and filtering it using VBA and putting the filtered data into a new worksheet. What I would like to be able to do is name the new worksheet based on where the data came from. For instance, if I ran my code on the Sept 2014 Raw Data worksheet, I would like my new sheet to be named Sept 2014, likewise for the Sept 2013 Raw Data. So, if there's some sort of code which can name the sheet from the first x amount of characters (in this case 9) that would be fantastic.

    Thanks for the help!
    Cody

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    OldShtName = "Sept 2013 Raw Data"
    LenNewSHtName = Instr(OldShtName, " Raw") - 1
    NewShtName = Left(OldShtName, LenNewShtName)
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    Where split comes in:

    c00=split(activesheet.name," Raw")(0)

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Where c00 = New Name
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

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