excel - Create new worksheet based on cell but ignore empty cell -
i create new worksheet in workbook; name based on information in c column (starting @ c4) of "summary" worksheet. have following vba far when gets blank cell stops. need ignore blank cells , continue. help?
sub createsheetsfromalisttest() dim mycell range, myrange range set myrange = sheets("summary").range("c4") set myrange = range(myrange, myrange.end(xldown)) each mycell in myrange sheets.add after:=sheets(sheets.count) 'creates new workbook sheets(sheets.count).name = mycell.value 'renames new workbook next mycell end sub
replace
set myrange = sheets("summary").range("c4") set myrange = range(myrange, myrange.end(xldown)) each mycell in myrange sheets.add after:=sheets(sheets.count) 'creates new workbook sheets(sheets.count).name = mycell.value 'renames new workbook next mycell
by
set myrange=range(sheets("summary").[c4],sheets("summary").cells(rows.count,"c").end(xlup)) each mycell in myrange if len(mycell.text)>0 sheets.add after:=sheets(sheets.count) 'creates new workbook sheets(sheets.count).name = mycell.value 'renames new workbook end if next mycell
Comments
Post a Comment