PDA

View Full Version : [SOLVED] Need help naming a worksheet based off another worksheet in VBA



codys21
06-12-2015, 11:56 AM
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

SamT
06-13-2015, 06:15 AM
OldShtName = "Sept 2013 Raw Data"
LenNewSHtName = Instr(OldShtName, " Raw") - 1
NewShtName = Left(OldShtName, LenNewShtName)

snb
06-13-2015, 06:40 AM
Where split comes in:


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

SamT
06-13-2015, 06:43 AM
Where c00 = New Name