From the course: Excel: Learning VBA

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Run a procedure when a cell range changes

Run a procedure when a cell range changes - Microsoft Excel Tutorial

From the course: Excel: Learning VBA

Run a procedure when a cell range changes

- [Lecturer] When you create an Excel workbook, you should almost always allow your users to change them. Of course, if you create a workbook or worksheet and don't want it to be changed, you need to detect when a change occurs and use event handlers to manage it. Managing the change might mean reversing it or it could mean asking the user if they're sure they want to make that change. In either case, you can use the worksheet underscore change event. I'll demonstrate how to use that and also how to avoid annoying loops that you can get into by creating code in the 07_02 change range workbook. You can find it in the chapter seven folder of the exercise files collection. In this workbook, I have a single worksheet with some data. But now, I want to switch to the Visual Basic Editor to show you the code that will check for when a range is changed on this worksheet. So I'll press alt F11, and then in the sheet one code…

Contents