How to add number of sheets in workbook

Closed
ravi - Mar 22, 2010 at 08:44 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Mar 23, 2010 at 08:01 AM
Hi all,

How i can add number of sheets using macro.

For Example.

i have assing A2 as a sheet count for addition how can i accomplish it.

means if i give value as a 2 in cell A2 then 2 sheet must be added into workbook and if again i reduce it to 1 second sheet has to delete automatically.

Thanks in advance.

Regards,

Ravi
Related:

1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Mar 23, 2010 at 08:01 AM
dim sheetChange as integer

sheetchange = cells(2, "A")

if (sheetchange>0) then

for i=1 to sheetchange
sheets.add
next

end if

For sheet delete, there is an issue. What sheets is to be deleted. Can any sheet be delete including the one from where vale in cells A2 was read ?


for i=1 to sheetchange

sheets(i).delete
next
0