Specific Cell Change event

zendog1960

Active Member
Joined
Sep 27, 2003
Messages
453
How would I modify the following specific code to run when just one cell changes? It is running now when anything on the sheet changes as I am aware that that is what the code currently is supposed to do.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Copy_Sheet
End Sub
Sub Copy_Sheet()
Dim wSht As Worksheet
Dim shtName As String
shtName = Sheets("Location Summary").Range("J11")
For Each wSht In Worksheets
    If wSht.Name = shtName Then
        MsgBox "Sheet already exists...Make necessary " & _
            "corrections and try again."
        Exit Sub
    End If
Next wSht
Sheets("Template").Copy After:=Sheets("Coin Count")
Sheets("Template").Name = shtName
Sheets(shtName).Move After:=Sheets("Location Summary")
Sheets(shtName).Range("A1") = shtName
Sheets("Template (2)").Name = ("Template")
Sheets("Location Summary").Activate
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
Code:
    If Target.Address(False, False) <> "A1" Then Call CopySheet
 

zendog1960

Active Member
Joined
Sep 27, 2003
Messages
453
I tried...No GO

This didn't do anything. Can you help?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.Address(False, False) <> "A1" Then Call Copy_Sheet
End Sub

Sub Copy_Sheet()
Dim wSht As Worksheet
Dim shtName As String
shtName = Sheets("Location Summary").Range("J11")
For Each wSht In Worksheets
    If wSht.Name = shtName Then
        MsgBox "Sheet already exists...Make necessary " & _
            "corrections and try again."
        Exit Sub
    End If
Next wSht
Sheets("Template").Copy After:=Sheets("Coin Count")
Sheets("Template").Name = shtName
Sheets(shtName).Move After:=Sheets("Location Summary")
Sheets(shtName).Range("A1") = shtName
Sheets("Template (2)").Name = ("Template")
Sheets("Location Summary").Activate
End Sub
 

zendog1960

Active Member
Joined
Sep 27, 2003
Messages
453
All I want is to have the code run in the event the data in J11 changes, nothing else.
 

facethegod

Well-known Member
Joined
Aug 1, 2006
Messages
767
Try this


Code:
If Not Target.Address() = Range("J11").Address() Then
    Exit Sub
Else: Call Copy_Sheet
End If



HTH FTG
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
or just:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$J$11" Then Call CopySheet
End Sub
 

Forum statistics

Threads
1,181,102
Messages
5,928,073
Members
436,587
Latest member
Slicesofquince

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top