View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Run macro automatically when a cell in a dynamic range changes

Hi Glimmer23.

Try:

Private Sub Worksheet_Change(ByVal target As Range)

Dim startCell As Range
Dim endCell As Range
Dim rng As Range

Set startCell = Me.Range(Me.Range("B8").Value)
Set endCell = Me.Range(Me.Range("C8").Value)

Set rng = Range(startCell, endCell)

If Not Intersect(target, rng) Is Nothing Then
Application.ScreenUpdating = False
Run "Model.MyHide"
End If
Application.ScreenUpdating = True

End Sub

I have intentionally changed the name of the called macro from Hide to
MyHide, because 'Hide' as a special significance for VBA and and the
potential subsequent confusion may cause subtle problems.


---
Regards,
Norman



wrote in message
oups.com...
Hi

my problem is hopefully pretty simple.

my code so far looks like this:

Private Sub Worksheet_Change(ByVal target As Range)
Application.ScreenUpdating = False
If Union(target, Range("$B$76:$B$114")).Address = "$B$76:$B$114" Then


End If
Application.ScreenUpdating = True
End Sub

which works fine for the range $B$76:$B$114 however the row numbers are
prone to change.

I have setup a table thats location will not change, which will store
the reference start and the reference ends. This is located at B8
(start) and C8 (End).

what i am tring to do is get the information from B8 and C8 to replace
the B76 and B114 respectively.

any ideas?