Can Worksheet_Change call itself?
Brad,
You'l l see what's wrong with that approach if you run this snippet of code
by changing a cell on the worksheet,
Private Sub Worksheet_Change(ByVal Target As Range)
For X = 4 To 5
Range("A16").Offset(0, X).Value = Range("A16").Offset(0, X).Value
MsgBox Target.Address
Next
End Sub
As you will note you will go into a recursive loop. Hit CTRL+Break. There
will be a way to do what you want but I doubt this is it. Post your code.
Mike
"Brad E." wrote:
You've got it correct. I am just trying to set the value so that
Worksheet_Change will be called with E16 the target and then again with F16
the target.
For each of the vehicles 4 and 5 (because we are increasing from the old
entry of "3"), I want to run further code which is already programmed in the
Worksheet_Change event, with B16:J16 the intersect.
--
Brad E.
-----------------------------------------------
"Mike H" wrote:
Hi,
I think you need to post your code becuse this bit doesn't seem to make sense
In a For loop (For X = 4 to 5, in this case), I have
Range("A16").Offset(0, X).Value = Range("A16").Offset(0, X).Value
It does nothing because for any value of X in the loop it becomes
Range("A16").Offset(0, 4).Value = Range("A16").Offset(0, 4).Value
in other words leave the value of that cell the same
Mike
"Brad E." wrote:
Hi,
In my Worksheet_Change event, I would like to change a cell and call the
Worksheet_Change event again.
In B3, the user enters a number up to 9, to access up to 9 vehicles. If the
old value was 3 and the user enters 5, then the Worksheet_Change acknowledges
the change and Displays some check boxes (Visible = True) for the 4th and 5th
column. The check boxes were hidden when B3 originally went smaller than 5
(Visible = False). The ability to use these check boxes also depends on the
entry in row 16. So first, I make the check boxes for vehicles 4 and 5
visible, and then want to re-enter the entry in row 16 for these 2 vehicles.
I thought if I just set a cell to a value, it would initiate the
Worksheet_Change event and the new Target would be the cell in row 16.
In a For loop (For X = 4 to 5, in this case), I have
Range("A16").Offset(0, X).Value = Range("A16").Offset(0, X).Value
Part of my Worksheet_Change event includes an intersection of Target and
"B16:J16", however the code after this intersection is not running.
What are my options to be able to run the code?
--
Thanks, Brad E.
|