Code not working - what is wrong.

Brutusar

Board Regular
Joined
Nov 23, 2019
Messages
166
Office Version
  1. 365
Platform
  1. Windows
Hi, I am using the code below to start a different Sub when the value of cell A1 in the active sheet is changed. However, the code is not working, meaning nothing is happening. The sub that is supposed to be started when the value is changed is working fine when run directly. I can't find my mistake in the code, but it must be something?


VBA Code:
 Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address = "$A$1" Then
    
        Call CopyAndAppendRange
    End If
    
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Your code says this:
Set wsCopy = ActiveSheet
I think you need to use the sheet name here.
Do not use active sheet.
 
Upvote 0
@Brutusar,

I don't think that you correctly understood Kevin's question:
What is causing the value in cell A1 to change? Is it by data entry of some kind, or is there a formula in that cell?
Is the data in the active sheet entered manually or is it from a "data dump" or a copy/paste from another source? Are you physically entering the value in A1 and then clicking away from the cell or pressing enter or using a directional arrow? In other words, is an event actually happening?

Cheerio,
vcoolio.
 
Upvote 0
When I try using your code this line of code is causing the problem:
Set wsCopy = ActiveSheet

The active sheet would be the sheet where your change event script is:

So, you should not use active sheet.

Use the actual sheet name.
 
Upvote 0

Forum statistics

Threads
1,215,110
Messages
6,123,146
Members
449,098
Latest member
Doanvanhieu

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
Back
Top