Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 270
Default Activecell problem

Hi
I am trying to have a piece of code run if a value in a range is changed.
What I have at the moment fails because the activecell when my last cell in
the range K20 is changed, the focus moves to the next cell (in this case
C30).

Current code :-

If Not Intersect(Activecell, Range("C14:K16, C20:K22")) Is Nothing Then

****Code*****

End if

How can I adjust to include any alteration to K22.

Also :-

I have a function EmptyRng :-

Function EmptyRng(myRng As Range)
Dim cella As Range
EmptyRng = False
For Each cella In myRng
If IsEmpty(cella) Then
EmptyRng = True
Exit Function
End If
Next cella
End Function

Ideally I would like the above code to run only if the Range("C14:K16,
C20:K22") has no empty cells.

I have tried :-

If Not Intersect(Activecell, Range("C14:K16, C20:K22")) Is Nothing _
And Not EmptyRng(Range("C14:K16, C20:K22") Then

***** Code *****

End If

But I get a Type Mismatch.

Thanks in advance for any assistance
Sandy

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Activecell problem

If you use the Worksheet Change event, you can test Target (which contains
the range of the change) rather than activecell.
--
Gary''s Student - gsnu2007k


"Sandy" wrote:

Hi
I am trying to have a piece of code run if a value in a range is changed.
What I have at the moment fails because the activecell when my last cell in
the range K20 is changed, the focus moves to the next cell (in this case
C30).

Current code :-

If Not Intersect(Activecell, Range("C14:K16, C20:K22")) Is Nothing Then

****Code*****

End if

How can I adjust to include any alteration to K22.

Also :-

I have a function EmptyRng :-

Function EmptyRng(myRng As Range)
Dim cella As Range
EmptyRng = False
For Each cella In myRng
If IsEmpty(cella) Then
EmptyRng = True
Exit Function
End If
Next cella
End Function

Ideally I would like the above code to run only if the Range("C14:K16,
C20:K22") has no empty cells.

I have tried :-

If Not Intersect(Activecell, Range("C14:K16, C20:K22")) Is Nothing _
And Not EmptyRng(Range("C14:K16, C20:K22") Then

***** Code *****

End If

But I get a Type Mismatch.

Thanks in advance for any assistance
Sandy


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
selecting multiple ActiveCell items (possibly loop problem) jono_dude Excel Programming 2 December 19th 06 12:37 AM
Help: Activecell within Do loop problem DavidShepherd Excel Programming 1 December 12th 05 09:54 AM
Activecell problem [email protected] Excel Discussion (Misc queries) 1 October 26th 05 02:13 PM
Sum Activecell Offset Problem George Andrews Excel Worksheet Functions 3 May 22nd 05 12:12 AM
activecell.address problem Jason Excel Programming 2 March 10th 05 10:12 PM


All times are GMT +1. The time now is 11:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"