Bill
I'm unsure what exactly you are trying to do as
there are a number of things that look @ odds to one another.
1) The worksheet change event will not be triggered
by a change via a control.
2) Which scrollbar are you using the one from the
Forms or Control tollbox ??
I suspect that you maybe using the Control tollbox
Can you elaborate further and also what code you may have and formulas.
Ivan
Ivan:
Here is the code for the worksheet change event:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ChangedCells As Range, StockConst As Range, StockVar As Range, NoCols As Integer, i As Integer, ActCol As Integer, x As Integer
Application.ScreenUpdating = False
Set ChangedCells = Range("b77:b79, b82:endcell")
Set SpConst = Range("b77:b79")
Set SpVar = Range("b81:endcell")
If Not Application.Intersect(StockConst, Range(Target.Address)) _
Is Nothing Then
Application.EnableEvents = False
NoCols = Range(cells(82, 2), cells(82, 2).End(xlToRight)).cells.Count
If NoCols = 1 Then x = 2 Else
x = NoCols + 1
For i = 2 To x
spreadcalc (i)
Next i
Application.EnableEvents = True
End If
If Not Application.Intersect(StockVar, Range(Target.Address)) _
Is Nothing Then
ActCol = ActiveCell.Column
spreadcalc (ActCol)
End If
Application.ScreenUpdating = True
End Sub
The two ranges, SpConst and SpVar, supply values to UDFs in other cells. The SpConst range contains variables that are universal(constant) while the SpVar range contains variable that are only applicable for a certain case. The goal here is to recalculate the UDFs by changing any of the variables. As written, the proceedure works when the cells are changed when manually entering a new value into a cell. I would like to limit the cells in SpConst to a range that could be controlled by a scroll bar. I am attempting to use the control toolbox (ActiveX?). What happens is that when the scrollbox changes the value in one of the cells, a loop that refers to each other begins until the limit of the scroll bar range is reached. I hope this clarifies what I'm trying to do but upon re reading this, I wouldn't bet on it. Thanks again for your help.
Bill Mason
Ivan:
Here is the code for the worksheet change event:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim ChangedCells As Range, StockConst As Range, StockVar As Range, NoCols As Integer, i As Integer, ActCol As Integer, x As Integer
Application.ScreenUpdating = False
Set ChangedCells = Range("b77:b79, b82:endcell")
Set SpConst = Range("b77:b79")
Set SpVar = Range("b81:endcell")
If Not Application.Intersect(StockConst, Range(Target.Address)) _
Is Nothing Then
Application.EnableEvents = False
NoCols = Range(cells(82, 2), cells(82, 2).End(xlToRight)).cells.Count
If NoCols = 1 Then x = 2 Else
x = NoCols + 1
For i = 2 To x
spreadcalc (i)
Next i
Application.EnableEvents = True
End If
If Not Application.Intersect(StockVar, Range(Target.Address)) _
Is Nothing Then
ActCol = ActiveCell.Column
spreadcalc (ActCol)
End If
Application.ScreenUpdating = True
End Sub
The two ranges, SpConst and SpVar, supply values to UDFs in other cells. The SpConst range contains variables that are universal(constant) while the SpVar range contains variable that are only applicable for a certain case. The goal here is to recalculate the UDFs by changing any of the variables. As written, the proceedure works when the cells are changed when manually entering a new value into a cell. I would like to limit the cells in SpConst to a range that could be controlled by a scroll bar. I am attempting to use the control toolbox (ActiveX?). What happens is that when the scrollbox changes the value in one of the cells, a loop that refers to each other begins until the limit of the scroll bar range is reached. I hope this clarifies what I'm trying to do but upon re reading this, I wouldn't bet on it. Thanks again for your help.
Bill Mason