vba - Weird Excel bug when deleting sheet with named ranges? -
i have excel workbook includes 2 worskheets, wkshta , wkshtb. both have local named ranges (the scope of each named range parent sheet). cells in wksht b reference named ranges in a, none of cells in reference named ranges in b.
i have macro creates copy of each sheet within same workbook. works fine.
the problem when delete worksheet a, name manager has bunch of #ref errors names on worksheet a, scope of each has been changed "workbook." however, happens if delete worksheet before delete worksheet b. if delete them in reverse order, named ranges in deleted sheet.
another weird thing if delete a, delete #ref errors, delete b, run macro makes new copies, delete again, #ref errors don't reappear.
i'm stumped... ideas? thanks.
turns out problem way defining references b a. instance, had range in , range in b both named "premium". had snippet of code said
worksheets("b").range("premium").formula = "='a'!premium"
this worked fine, when deleted worksheet a, named range didn't delete. changing formula definition to
worksheets("b").range("premium").formula = "='a'!" & worksheets("a").range("premium").address
did trick
Comments
Post a Comment