Thread: Code Problem
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Code Problem

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim sh as Worksheet
If Target.Rows.Count 1 Then Exit Sub
Application.EnableEvents = False
On Error Resume next
set sh = worksheets(Cells(Target.row,1).Value)
On Error goto 0
if not sh is nothing then
Target.EntireRow.Copy sh.Rows(1)
end if
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy


"TC" wrote in message
m...
I'm running this code to select from one worsheet a row that places
data on another sheet. The code works great until I click on a blank
row. I get a run time error subscript out of range. Here is the code
can anyone help?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Rows.Count 1 Then Exit Sub
Application.EnableEvents = False
*Debugshere Target.EntireRow.Copy Worksheets(Cells(Target.Row,
1).Value).Rows(1)
Application.EnableEvents = True
End Sub