ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating a copy of a worksheet II (Just 2 more things please...) (https://www.excelbanter.com/excel-programming/285375-creating-copy-worksheet-ii-just-2-more-things-please.html)

M Hill

Creating a copy of a worksheet II (Just 2 more things please...)
 
JE, thank you.

It does what I want thank you.
Just 2 more things Id like with this project...

To recap:
2 worksheets: 'TOC' and 'TEMPLATE'

So far your code:
Creates a new worksheet when I enter in text on TOC based on the template
worksheet and assigns it the new name of the row number I am in from the TOC
worksheet (fantastic!).


When I enter in text into TOC worksheet, lets say in cell A3 (or any row
from TOC):
I would like the text I type into this cell to be entered into cell A1
(always cell A1 no matter what row I am in from TOC) of the newly created
worksheet.
I would then like cell I am currently in (eg.A3) of the TOC worksheet to be
hyperlinked to the newly created worksheet.


Your great code....

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim wkSht As Worksheet
Dim result As Integer
Dim sName As String
With Target
If .Count 1 Then Exit Sub
sName = .Row
End With
On Error Resume Next
Set wkSht = Worksheets(sName)
On Error GoTo 0
If Not wkSht Is Nothing Then
result = MsgBox( _
Prompt:="Delete current sheet " & sName & "?", _
Buttons:=vbYesNo)
If result = vbNo Then
With Application
.EnableEvents = False
.Undo
.Goto Target
.EnableEvents = True
Exit Sub
End With
Else
Application.DisplayAlerts = False
wkSht.Delete
Application.DisplayAlerts = True
End If
End If
Worksheets("Template").Copy After:=Sheets(Sheets.Count)
ActiveSheet.Name = sName
End Sub



--


---------------------------------------------------------------------
"Are you still wasting your time with spam?...
There is a solution!"

Protected by GIANT Company's Spam Inspector
The most powerful anti-spam software available.
http://mail.spaminspector.com





All times are GMT +1. The time now is 11:16 PM.

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