change event

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

Guest

I am using a change event to call a macro when any field in a specified
column is changed. The code appears below. Generally, only one cell at a
time will be changed, but in the even the user changes multiple cells at once
(e.g. pastes values) this code does not work because the target is a range
rather than a single cell. Can anyone help me to adapt the code to handle a
range rather than a single cell? Thanks much in advance.
 
Yeah I realized that at about the same time I clicked on Post.

Private Sub Worksheet_change(ByVal Target As Range)
Dim n As Integer

If Target.Column = 5 Then
If Target.Value = "Done" Then
n = Target.Row
Rows(n).Cut
Call moveEntry(n)
End If
End If
 
You should not mixup Range and a single Cell, since a range may consist of
several cells and subranges.

Hope i didn't confused you to much


Greetings Jonjo
 
err.... code?

As a guess you might try using something like:

dim c as range

for each c in ChangedRange
'process cell
next c


Tim.
 
Private Sub Worksheet_Change(ByVal Target As Range)
Dim N As Integer
Dim cell As Range

If Target.Column = 5 Then
For Each cell In Target
If cell.Value = "Done" Then
N = cell.Row
Rows(N).Cut
Call moveEntry(N)
End If
Next cell
End If

End Sub




--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Sorry here it comes:


Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range
For Each r In Target.Areas
Debug.Print r.Address
Next
End Sub

As you can see, every change will be printed out in the Direct window, try
it out

Greetings Jonjo
 

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