excel - Create new sheets based on a list -


when create new sheets based on below vba code, works want, there small problem. issue when creating sheets based on list given in column ("a"), create 1 more sheet same name of original 1 , show error in code in section

activesheet.name = c.value 

any assistant correct.

private sub commandbutton1_click()     on error resume next     application.enableevents = false     dim bottoma integer     bottoma = range("a" & rows.count).end(xlup).row     dim c range     dim ws worksheet     each c in range("a2:a" & bottoma)         set ws = nothing         on error resume next         set ws = worksheets(c.value)         on error goto 0         if ws nothing             sheets("format").select             sheets("format").copy after:=sheets(sheets.count)             activesheet.name = c.value         end if     next     application.enableevents = true end sub 

i think forgot in statement state worksheet range on. line should this:

for each c in worksheet(1).range("a2:a" & bottoma)

also there other issue in code, made quick re-write..

private sub commandbutton1_click()         dim c range     dim ws worksheet     dim bottoma integer      on error goto eh      application.enableevents = false      bottoma = range("a" & rows.count).end(xlup).row      each c in worksheets(1).range("a2:a" & bottoma)        'set ws = nothing        'on error resume next        'set ws = worksheets(c.value)        'on error goto 0        'if ws nothing         sheets("format").select         sheets("format").copy after:=sheets(sheets.count)         activesheet.name = c.value        'end if next application.enableevents = true  exit sub  eh:     debug.print ""     debug.print err.description     msgbox (err.description) end sub 

Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -