Change Event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I would like a macro to run when a specific range of cells are changed, but
I do not want it to run if any other cells are changed. For instance if any
cell in the range A1:A25 are change I would like the macro to run. But I do
not want it to run if any other cell on the worksheet is changed. Is this
possible?

Thank you,
 
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 and Target.Row < 26 Then
<Perform Macro>
End If
End Sub

--

Sincerely,

Ronald R. Dodge, Jr.
Master MOUS 2000
 
What should happen if the user changes a range of cells, some in and some
out of the specific range? Say by pasting to A20:A30 or selecting A1:B10,
C5:D15, A18:A22 typing an entry and pressing Ctrl-Enter?

--
Jim
| Hello,
|
| I would like a macro to run when a specific range of cells are changed,
but
| I do not want it to run if any other cells are changed. For instance if
any
| cell in the range A1:A25 are change I would like the macro to run. But I
do
| not want it to run if any other cell on the worksheet is changed. Is this
| possible?
|
| Thank you,
 
That is where Target.Rows.Count with Target.Row will need to be taken into
account. This is also true for Target.Columns.Count with Target.Column.

However, this could be a problem as if multiple different range selections
is selected, then a value typed in, then pressed Ctrl-Enter, which case
would also require using Target.Areas, such as

If Target.Areas.Count>1 Then
'There are multiple range areas selected.
Else
'There is only one area selected.
End If

Such example of multiple areas would be like if A5:B8, A11:A15, C8:F24 were
all selected and the only cells selected, then the user typed in something
like the numeric value of "0", then pressed Ctrl-Enter.

--

Sincerely,

Ronald R. Dodge, Jr.
Master MOUS 2000
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top