View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rowan Drummond[_3_] Rowan Drummond[_3_] is offline
external usenet poster
 
Posts: 414
Default Switch cells on input

Hi Deepak

1. When you are entering some data in a cell, your selection or target
range will always be 1 cell. So you event procedure will never go
beyond line 1 since you cell count will never be greater than 1.


The line of code is "If Target.Cells.Count 1 Then Exit Sub" so it will
only exit if more than one cell is changed at a time. Usually used to
trap users pasting a range, deleting a row etc.

2. You can never enter any data in more than 1 cell at any one time
from the front end.


Select a range of cells on a sheet. Type some data and hit Ctrl+Enter.
You've just entered the same data in the entire range all at the same time.

However, you will need to disable your event procedures before you make
any changes to any cell to avoid the cascading effect.


The Application.EnableEvents commands are included in the original event.

Kind Regards
Rowan

agarwaldvk wrote:
Dan

I don't think you can get what you want to do by doing what you are
doing?

A couple of reasons :-

1. When you are entering some data in a cell, your selection or target
range will always be 1 cell. So you event procedure will never go
beyond line 1 since you cell count will never be greater than 1.

2. You can never enter any data in more than 1 cell at any one time
from the front end.

What you can do is write a Worksheet_Change event procedure and check
for the contents of cells in columns 'F' and 'H' for the same row say
contents of cells(5,6) and cells(5,8) and if both these cells contain a
value of 1, then clear both these cells and insert a 1 in cell(5,4).

However, you will need to disable your event procedures before you make
any changes to any cell to avoid the cascading effect. I take it that
you are aware of the two ways of doing so viz Disable applicationEvents
or create a static variable and insert the corresponding code as the
first line of your event procedure.


Best regards


Deepak Agarwal