ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to Create Sheet & Duplicate Sheet (https://www.excelbanter.com/excel-programming/363624-macro-create-sheet-duplicate-sheet.html)

Herve_Rob

Macro to Create Sheet & Duplicate Sheet
 

Hi,
could anyone tell me how - in a VB macro - to :
1) Create a sheet
In a Workbook, I have one Sheet called "Sheet1"
If on "Sheet1" Cell A1 = TOTO a macro will *create* a sheet calle
TOTO

2) Duplicate a sheet
If on "Sheet1" Cell A1 = TITI a macro will *duplicate* "sheet 1"

Regards

Herv

--
Herve_Ro
-----------------------------------------------------------------------
Herve_Rob's Profile: http://www.excelforum.com/member.php...fo&userid=3520
View this thread: http://www.excelforum.com/showthread.php?threadid=54968


Bearacade[_7_]

Macro to Create Sheet & Duplicate Sheet
 

Sub Macro()

If Sheets("Sheet1").Range("A1").Value = "TOTO" Then

Sheets.Add
With ActiveSheet
Name = "TOTO"
End With

Sheets("Sheet1").Select

End If

If Sheets("Sheet1").Range("A1").Value = "TITI" Then

Sheets("Sheet1").Select
Sheets("Sheet1").Copy Befo=Sheets(2)

End If

End Sub


--
Bearacade


------------------------------------------------------------------------
Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016
View this thread: http://www.excelforum.com/showthread...hreadid=549682



All times are GMT +1. The time now is 01:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com