Deleting tabs when a cell is emptied

Hello everyone,

I have an excel macro where, whenever i put a name into a cell in the range B43 to B77 on the very first worksheet, a new worksheet is created that has the name of whatever is put into the cell.

what i would like to be able to do is to create a macro that would, whenever one of the cells is cleared, to delete that specific worksheet that was created when the name was entered.

any help is appreciated :D

Nick

[463 byte] By [Snowrider] at [2007-12-23]
# 1

This should be fairly easy to do. Since you've already got code that creates a sheet when a value is added within that range, I'd recommend creating a Collection which contains Items equal to the name of the sheet (the value of the cell) with Keys equal to Range.Address of the cell in which they're entered.

Then, when the Worksheet_Change() event is called, you can:

- check the Target.Address parameter to ensure that it's within the range B43:B77

- if Target.Value is null, select the appropriate worksheet from your Collection using Target.Address as the key, and delete that worksheet

duckthing at 2007-8-30 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...