Macro copy rows based on specific column value

  • Hello,

    Based on the old thread:

    Macro copy rows to sheets

    The code it's working fine but I have problems when the sheet names exceeds 31 characters

    How can I modify the code to truncate the name below 31 chars even it's longer ?

    I got the following message: You typed an invalid name for sheet (pic attached)




  • Try this...

    1. Sheets.Add(after:=Sheets(Sheets.Count)).Name = Left(e, 31)

    I got error: Runtime error '9': Subscript out of range


    .Parent.Cells.Copy Sheets(e).Cells(1)

    It's starting to rename within 31 chars until above error.

  • Try it this way...

    If I've been helpful, let me know. If I haven't, let me know that too.