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

Community
  • 1
  • 1
Tom
  • 9,725
  • 3
  • 31
  • 48

1 Answers1

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
Ross McConeghy
  • 874
  • 2
  • 7
  • 16
  • excuse possibly my naivety but isn't that only monitoring one textbox? – Tom Aug 22 '14 at 14:54
  • `TextChanged ` <~ 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. – Ross McConeghy Aug 22 '14 at 14:55