Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() try If Target.Rows.Count 1 or target="" Then -- Don Guillett SalesAid Software "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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If multiple cells are selected, this will produce a type mismatch error.
-- Regards, Tom Ogilvy "Don Guillett" wrote in message ... try If Target.Rows.Count 1 or target="" Then -- Don Guillett SalesAid Software "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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
We need not understand everything, need we?
-- Don Guillett SalesAid Software "Tom Ogilvy" wrote in message ... Not sure I understand. Do you mean if you hadn't suggested a flawed solution, it wouldn't have been problematic? Agreed. -- Regards, Tom Ogilvy "Don Guillett" wrote in message ... The patient said "Doctor, it hurt when I do this". The doc said "Don't do that" -- Don Guillett SalesAid Software |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Only those things we are going to give advice on, I suppose.
-- Regards, Tom Ogilvy "Don Guillett" wrote in message ... We need not understand everything, need we? -- Don Guillett SalesAid Software "Tom Ogilvy" wrote in message ... Not sure I understand. Do you mean if you hadn't suggested a flawed solution, it wouldn't have been problematic? Agreed. -- Regards, Tom Ogilvy "Don Guillett" wrote in message ... The patient said "Doctor, it hurt when I do this". The doc said "Don't do that" -- Don Guillett SalesAid Software |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom, Lighten up.
BTW. The question was click on a blank row - not a selection of row(S) -- Don Guillett SalesAid Software "Tom Ogilvy" wrote in message ... Only those things we are going to give advice on, I suppose. -- Regards, Tom Ogilvy "Don Guillett" wrote in message ... We need not understand everything, need we? -- Don Guillett SalesAid Software "Tom Ogilvy" wrote in message ... Not sure I understand. Do you mean if you hadn't suggested a flawed solution, it wouldn't have been problematic? Agreed. -- Regards, Tom Ogilvy "Don Guillett" wrote in message ... The patient said "Doctor, it hurt when I do this". The doc said "Don't do that" -- Don Guillett SalesAid Software |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Code problem | Excel Discussion (Misc queries) | |||
VB Code Problem | Excel Discussion (Misc queries) | |||
Problem with VBA Code? | Excel Programming | |||
Code problem | Excel Programming | |||
Code Problem ! | Excel Programming |