How to add number of sheets in workbook [Closed]

Report
-
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
-
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

1 reply

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
767
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

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!