VBA Worksheet_Change Not Firing

lizziebee

New Member
Joined
Apr 16, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I'm a VBA beginner and have been following this youtube video (
) by Excel for Freelancers to make a template similar to my needs.

At about the 48 minute mark, this private sub was made to prevent a user from editing more than one cell at once:

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("D4:K6")) Is Nothing Then
    If Target.Count > 1 Then
        Application.ScreenUpdating = False
        Application.Undo
        Application.ScreenUpdating = True
        End
    End If
End If
End Sub

I followed the instructions, inserting the above into the correct sheet. However, nothing happens when I edit more than one cell (e.g. delete the contents of two cells at once)? No errors are flagged when I run the code.

Any thoughts? I've tried searching other forums but can't find a solution.

Thanks
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Just to add to this - I downloaded Excel for Freelancer's version of the workbook and the sub procedure didn't seem to work on this either. Yet in the video it did.
 
Upvote 0
VBA Code:
 If Target.Count > 1 Then

The above line is specifying only if more than a single cell is changed at the same time. Although the macro may not
function as designed there .... in a test here ... it works.

I do not have an explanation why the macro is not working for you.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

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