vba - Rename tabs with same name in an Excel sheet -


i trying rename tabs in large excel using cell value in each worksheet. issue is, rename multiple tabs same name, not allowed. ok adding 1, 2 etc not sure how that.

for example if cell value in 3 sheets ohio, tabs ohio1, ohio2, ohio3.

the name of each sheet should value in a1, want account duplicate names.

the vba code without accounting same name is:

sub worksheet_selectionchange() dim ws worksheet  each ws in sheets ws.activate activesheet.name = range("a1").value  next ws  end sub 

sub worksheet_selectionchange() dim ws worksheet dim integer  = 1  on error goto fixname  each ws in me.worksheets  ws.name = ws.range("a1").value   next ws   exit sub fixname: ws.name = ws.range("a1").value & i = + 1  end sub 

Comments