This is my very first attempt at writing some visual basic for excel and I am struggling to get it to loop, I am trying to get get the code to recalculate cells when a new figure is entered in, in this instance I have only entered 2 cases but I plan to have about 30 or so cases/cells its watching at the end. This works for the first case but doesn’t work for the second and any others put in afterwards, can anyone help me get this to work, as I want it to constantly watch numerous cells and recalculate other cells values whenever someone changes them. It also seems to work once on the first case and then not again, when the cell is changed again.
I basically need it to enter different formulas into the cells when they are changed as depending on what was changed a different formula will be required to recalculate the other cells.
Also the A1:ZZ10000 was me effectively trying to say the when any cell on the whole sheet was changed, but I know there’s a better way to do this but I couldn’t find it.
Any Help would be much appreciatedCode:Private Sub Worksheet_Change(ByVal Target As Excel.Range) Application.EnableEvents = 0 Dim row As Integer, col As Integer Do If Not Intersect(Target, Range("A1:ZZ10000")) Is Nothing Then For Each Cell In Intersect(Target, Range("A1:ZZ10000")) Select Case Cell(Target.Range) ' DACH FY11 Cell Changes: Case Target.Range("F7"): Range("F13").Select ActiveCell.Formula = "=Sum(R7C6/100)*R16C6*100" Range("F43").Select ActiveCell.Formula = "=Sum(R7C6/100)*R46C6*100" Range("F73").Select ActiveCell.Formula = "=Sum(R7C6/100)*R76C6*100" ' DACH FY12 Cell Changes: Case Target.Range("G7"): Range("G13").Select ActiveCell.Formula = "=Sum(R7C7/100)*R16C7*100" Range("G43").Select ActiveCell.Formula = "=Sum(R7C7/100)*R46C7*100" Range("G73").Select ActiveCell.Formula = "=Sum(R7C7/100)*R76C7*100" End Select Next Cell End If Loop Application.EnableEvents = 1 End Sub
Thanks


Reply With Quote

