View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Russ Russ is offline
external usenet poster
 
Posts: 108
Default surpressing listbox changes

Susan,
I think what you propose works similar to the AutoAction boolean variable in
my example code for the textbox. The routine runs only once surpressing the
change in the textbox. I am trying to surpress a listbox from changing when
clicked on when a test in the change procedure fails. I am working up a
simple example to show the problem.
Thanks for your try.
--
russ


"Susan" wrote:

maybe this would work - you could have a non-visible boolean checkbox
that, when the spreadsheet opens, sets itself to false. when the
change procedure is run, it checks for the boolean value & only runs
if the value is false. @ the end it changes that boolean value to
true.
so the change will only run once each time the workbook is opened.
i've done this kind of thing on userforms & don't know if you can
modify the theory to work with spreadsheet controls, but i think you
could.
OR you could use a value on a hidden worksheet that would act as the
boolean.
susan


On Mar 14, 11:17 pm, "Doug Glancy"
wrote:
Russ,

It works for me.

I changed the "triggering code" to:

.Text = .Text & "A"

Without your AutoAction check, the textbox fills with "A"s. With it, one
"A" is added for each letter I type in the box, which is what I would
expect.

hth,

Doug

"Russ" wrote in message

...



I have a listbox on a sheet. In the listbox change procedure I do a test.
If the test is positive I want to suppress the listbox from changing . I
tried to do this by changing the listbox.listindex to the previous value.
However, that triggers the change procedure again. I tried to use a
modification of this code but to no avail.
Private Sub TextBox1_Change()
Static AutoAction As Boolean
Dim TabPos As String
If AutoAction = True Then
Exit Sub
End If
AutoAction = True
With Me.TextBox1
' Your code here.
' For example,
.Text = Replace(.Text, Chr(9), "")'tiggering code
End With
AutoAction = False
End Sub
In this code the triggering code does not trigger the second time thru.
In
my case it does. I welcome any suggestions.


--
russ- Hide quoted text -


- Show quoted text -