View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Andibevan[_3_] Andibevan[_3_] is offline
external usenet poster
 
Posts: 11
Default Worksheet Change Event Problem

Hey Tim,

If you call your code from the bit which says 'do something' and change the
range to your desired range that should solve (1).

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Application.Intersect(Target, Range("A1:A10")) Is Nothing
Then
' do something'
End If
End Sub

As for why it doesn't run, are you sure that your named range output_period
exists? are you also sure that Year1_inspMon is a named range?

Regards

Andi


"tim" wrote in message
...
Howdy,
I am looking at one cell defined as "output_period", and when it changes I
want to update the sheet with a range from another sheet. I have a couple
of
questions;
1) the output_period is controlled by a Forms combo-box, and the macro
does
not seem to fire based on that change. Is there another event I should
consider (preference would be not to use ActiveX).
2) normal cell editing does cause the macro to fire, however it hangs at
the
"set getRange" line. Method 'Range' of object '_worksheet' failed. I
have
used similar code in non-event type macros without a problem, and I am not
sure what is wrong.

Here is the code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

Dim getRange As Range
Dim outRange As Range
Dim k As Integer

k = Range("output_period")

If Not Intersect(Target, Me.Range("output_period")) Is Nothing Then
Set getRange = Range("Year1_inspMon").Offset(0, k - 1)
Set outRange = Range("out_inspect_loc")

getRange.Copy Destination:=outRange

End If

End Sub

TIA,
Tim