Subroutine for change to a value on a worksheet

craigyg

Board Regular
Joined
Dec 14, 2005
Messages
114
Hope this question isn't too vague but here goes:

I am able to write subs based on click and change events for a button. I would like to be able to write the same kind of subs for change to a value or range of values on a worksheet. How can i do this?

Thanks-

Craig
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Craig

You would use worksheet or workbook events.

To access a worksheet's module, where the code will go, right click it's tab and select View Code.

You should now have 2 dropdowns above a code window.

If you select Worksheet from the left one you should see this.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub
This is the default event for a worksheet and is triggered when selection on the worksheet changes.

The parameter Target is the range that was changed.

There are various other worksheet events that you'll see listed in the right dropdown.
 
Upvote 0
Userform

Related question: What about if I want to do the same thing as before but I want this subroutine to be inside a userform module? (I would like this change to the worksheet to initiate changes on the userform).
 
Upvote 0
craig

Can you give more information?

There are various ways you can have worksheets/userforms interact with each other.
 
Upvote 0

Forum statistics

Threads
1,214,656
Messages
6,120,762
Members
448,991
Latest member
Hanakoro

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