close

Hi all,
I have a datasheet that I’ve written some code to find the first empty row.
I will then enter data across that row to Column M. I will enter some data
in Column K that I want to check by running some IF statements when I leave
the current cell in Column K. What I don’t know how to do is how to call that
routine when I leave the current cell in Column K.
Is it possible?
Any help or suggestions are always appreciated.Hi Jeff,

Try:

'=============gt;gt;
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range

If Target.Count gt; 1 Then Exit Sub

Set rng = Me.Columns(quot;Kquot;)

If Not Intersect(Target, rng) Is Nothing Then
'Your processing code
End If

End Sub
'lt;lt;=============---
Regards,
Norman
quot;jeffPquot; gt; wrote in message
...
gt; Hi all,
gt; I have a datasheet that I've written some code to find the first empty
gt; row.
gt; I will then enter data across that row to Column M. I will enter some
gt; data
gt; in Column K that I want to check by running some IF statements when I
gt; leave
gt; the current cell in Column K. What I don't know how to do is how to call
gt; that
gt; routine when I leave the current cell in Column K.
gt; Is it possible?
gt; Any help or suggestions are always appreciated.
gt;
Hi Jeff,

The suggested code represents an event procedure and should be pasted into
the worksheet code module - not a standard module.

If you want to run an existing procedure when a column K cell is changed,
add a line like:

Call MyMacro

as your processing code.---
Regards,
Norman
Norman,
this works terrific although I truly don't understsand the quot;If not is
nothing quot; statement. I'll keep trying to understand so someday...I can write
them myself.
In the meantime, I still need help. When this runs I call some nested IF's
to check and proceed on different answers. My problem is the the Work_Sheet
change is just that: if the cell is left empty (which I don't want to allow)
no change happens to call the trailing code. Can I somehow check for a blank
cell, with this or some other way.

As always any help and education is greatly appreciated

quot;Norman Jonesquot; wrote:

gt; Hi Jeff,
gt;
gt; The suggested code represents an event procedure and should be pasted into
gt; the worksheet code module - not a standard module.
gt;
gt; If you want to run an existing procedure when a column K cell is changed,
gt; add a line like:
gt;
gt; Call MyMacro
gt;
gt; as your processing code.
gt;
gt;
gt; ---
gt; Regards,
gt; Norman
gt;
gt;
gt;

Hi Jeff,

gt; this works terrific although I truly don't understsand the quot;If not is
gt; nothing quot; statement.

The following lines are intended to limit macro action to changes in a
column K cell:

gt;gt; Set rng = Me.Columns(quot;Kquot;)

gt;gt; If Not Intersect(Target, rng) Is Nothing Then

I would have liked to say:

If Intersect(Target, rng) Is Something Then

but the keyword something does not exist. Since, however, the keyword
Nothing does exist, I use this with a double negative to obtain a valid
equivalent expression.

gt; My problem is the the Work_Sheet change is just that: if the cell is
gt; left empty (which I don't want to allow) no change happens to call
gt; the trailing code. Can I somehow check for a blank cell, with this
gt; or some other way.

As written, the code is invoked in response to a change in a column K cell:
if an entry is deleted (so that the cell becomes blank), the code will run.

Would your purpose be satisfied if code were to check the column K cell when
an entry is made in the corresponding column L:M cells?

---
Regards,
Norman
quot;jeffPquot; gt; wrote in message
news
gt; Norman,
gt; this works terrific although I truly don't understsand the quot;If not is
gt; nothing quot; statement. I'll keep trying to understand so someday...I can
gt; write
gt; them myself.
gt; In the meantime, I still need help. When this runs I call some nested IF's
gt; to check and proceed on different answers. My problem is the the
gt; Work_Sheet
gt; change is just that: if the cell is left empty (which I don't want to
gt; allow)
gt; no change happens to call the trailing code. Can I somehow check for a
gt; blank
gt; cell, with this or some other way.
gt;
gt; As always any help and education is greatly appreciated
Norman,
Thanks for the explaination/education. At least on the right track. I was
trying to quot;simplifyquot; the code by eliminating the double negatives so MY logic
:
If Intersect(target,rng) then
but alas..........
gt;gt;not allowing blank cell : cells L:M are possible empty but these would be allowed. I do have a column (B) where data would be mandatory for the row/record to exist so MY logic is somewhere a test like
If B5 gt;quot;quot; Then
but I don't know if this is a proper test or where to put it. As you know MY
logic and VBA logic is not necessarily compatible
thanks again
jeffpquot;Norman Jonesquot; wrote:

gt; Hi Jeff,
gt;
gt; gt; this works terrific although I truly don't understsand the quot;If not is
gt; gt; nothing quot; statement.
gt;
gt; The following lines are intended to limit macro action to changes in a
gt; column K cell:
gt;
gt; gt;gt; Set rng = Me.Columns(quot;Kquot;)
gt;
gt; gt;gt; If Not Intersect(Target, rng) Is Nothing Then
gt;
gt; I would have liked to say:
gt;
gt; If Intersect(Target, rng) Is Something Then
gt;
gt; but the keyword something does not exist. Since, however, the keyword
gt; Nothing does exist, I use this with a double negative to obtain a valid
gt; equivalent expression.
gt;
gt; gt; My problem is the the Work_Sheet change is just that: if the cell is
gt; gt; left empty (which I don't want to allow) no change happens to call
gt; gt; the trailing code. Can I somehow check for a blank cell, with this
gt; gt; or some other way.
gt;
gt; As written, the code is invoked in response to a change in a column K cell:
gt; if an entry is deleted (so that the cell becomes blank), the code will run.
gt;
gt; Would your purpose be satisfied if code were to check the column K cell when
gt; an entry is made in the corresponding column L:M cells?
gt;
gt; ---
gt; Regards,
gt; Norman
gt;
gt;
gt;
gt; quot;jeffPquot; gt; wrote in message
gt; news
gt; gt; Norman,
gt; gt; this works terrific although I truly don't understsand the quot;If not is
gt; gt; nothing quot; statement. I'll keep trying to understand so someday...I can
gt; gt; write
gt; gt; them myself.
gt; gt; In the meantime, I still need help. When this runs I call some nested IF's
gt; gt; to check and proceed on different answers. My problem is the the
gt; gt; Work_Sheet
gt; gt; change is just that: if the cell is left empty (which I don't want to
gt; gt; allow)
gt; gt; no change happens to call the trailing code. Can I somehow check for a
gt; gt; blank
gt; gt; cell, with this or some other way.
gt; gt;
gt; gt; As always any help and education is greatly appreciated
gt;
gt;
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()