View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 408
Default Worksheet Change Event Problem

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