Link to home
Start Free TrialLog in
Avatar of Jagwarman
Jagwarman

asked on

copy data to new sheets each time name changes

Can an expert provide VBA code for this please.

For each change of name in column B I need to copy both the header and all the data from rows A to O to a new sheet and name the sheet with the name that is in Cell B

have attached a file to help explain.

Many thanks
Avatar of Jagwarman
Jagwarman

ASKER

Hmmm file did not attach
copy_Sheets.xlsx
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Rgonzo, you are amazing just what I need many many thanks
Excellent Rgonzo1971

i am a excel learner, so i have two question on this code.

1- i added some new data with different in column B and Column A and then ran the macro then i get an error in line 11 and it says "Run time error 1004
Cannot Rename a sheet to the same name as another sheet a referenced object library or a workbook referenced by Visual Basic."

2- i got confused with "lastvalue"  you have not set any value or i do not see any reference before for "lastvalue" can you please explain why have you used If c.Value <> lastvalue Then
        lastvalue = c.Value    becuase "lastvalue"  obiously has no value and c.value is definitely is not equal to c.value , so wouldn't this work instead  lastvalue=c.Value


grateful if you could shed light on this.

i opened a question for this here https://www.experts-exchange.com/questions/28710546/VBA-question-relatated-to-another-answer-given.html

please answer it there, so that you could also get the points for it.