1

I am trying to monitor a sheet which has several text boxes on it.

The idea behind it is the user enters text into these boxes and then you can click the submit button to send it all to a sql database.

Now I want to have it so if the user has made changes, and they go to leave the sheet a macro is triggered to tell them that they haven't saved it.

I've already got this triggering on the deactivate worksheet event, but I was wondering if I can monitor all of the textboxes on the sheet (oleobjects) under one change event

I am already assuming this isn't possible with just one but was hoping.

Thanks in advance

Tom

1 Answer 1

2

One way to do this would be to write a separate subroutine that is called within the Change event of all the Textboxes. Keep in mind though that this will be raised every time the Textboxes change at all- every keystroke.

In each TextBox_Change Event:

Private Sub TextBox1_Change()
    TextChanged TextBox1
End Sub

New subroutine:

Sub TextChanged(fromTextBox As TextBox)
    'validation code goes here
End Sub
Sign up to request clarification or add additional context in comments.

2 Comments

excuse possibly my naivety but isn't that only monitoring one textbox?
TextChanged <TextBox Name> <~ This goes in the Change event for every Textbox. In the TextChanged() subroutine you can use fromTextBox to directly access the Textbox the event was raised from.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.