Worksheet Change Problem

  • Thread starter Thread starter Phil Floyd
  • Start date Start date
P

Phil Floyd

I am manually copying from one sheet a row of cells (A:G) . I then will
paste it into another workbook in a row such as A2:G2 which means that this
entire range remains highlighted. After the paste I would like to select H2
but because of the highlighted range, the code below won't work.



Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$A$2" Then

Range("H2").Select

End If

End Sub



If you copy and paste only in A2 then H2 is selected. Is there a work
around for this.



Thanks,

Phil
 
Intersect is probably your solution here:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A2")) Is Nothing Then
Range("H2").Select
End If
End Sub
 
Hi Phil
try something like the following:


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Me.Range("A2:G2")) Is Nothing Then Exit Sub
Range("H2").Select
End Sub
 

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