![]() |
Problem Pasting entire row.
I am having a problem pasting all of the row in sheet1. It pastes the row
starting with the cell that is found and everything to the right, but nothing to the left. If anyone can help that would be nice. Here is the code. Thanks -mark Private Sub cmdFind_Click() Dim wksCopyFrom As Worksheet Dim wksCopyTo As Worksheet Dim rngToSearch As Range Dim rngFound As Range Dim rngCopyTo As Range Set wksCopyTo = Sheets("Search_Add") For Each wksCopyFrom In Worksheets If wksCopyFrom.Name < wksCopyTo.Name And _ wksCopyFrom.Name < "Search_Add" Then 'sheets you don't want searched Set rngToSearch = wksCopyFrom.Cells Set rngFound = rngToSearch.Find(txtFind.Text, , xlValues, LookAt:=xlPart) If Not rngFound Is Nothing Then 'If rngCopyTo.Offset.Value < "" Then 'rngFound.Offset(1, 0).EntireRow.Insert Set rngCopyTo = wksCopyTo.Cells(Rows.Count, "A").End(xlUp).Offset(2, 0) rngFound.EntireRow.Copy rngCopyTo End If End If 'End If Next wksCopyFrom txtFind.Text = "" Sheets("Search_Add").Activate End Sub |
Problem Pasting entire row.
EntireRow should copy the EntireRow. I have never seen it fail:
set rngFound = Range("F13") ? rngfound.Address $F$13 ? rngFound.entireRow.Address $13:$13 -- Regards, Tom Ogilvy "Mark Cover" wrote in message ... I am having a problem pasting all of the row in sheet1. It pastes the row starting with the cell that is found and everything to the right, but nothing to the left. If anyone can help that would be nice. Here is the code. Thanks -mark Private Sub cmdFind_Click() Dim wksCopyFrom As Worksheet Dim wksCopyTo As Worksheet Dim rngToSearch As Range Dim rngFound As Range Dim rngCopyTo As Range Set wksCopyTo = Sheets("Search_Add") For Each wksCopyFrom In Worksheets If wksCopyFrom.Name < wksCopyTo.Name And _ wksCopyFrom.Name < "Search_Add" Then 'sheets you don't want searched Set rngToSearch = wksCopyFrom.Cells Set rngFound = rngToSearch.Find(txtFind.Text, , xlValues, LookAt:=xlPart) If Not rngFound Is Nothing Then 'If rngCopyTo.Offset.Value < "" Then 'rngFound.Offset(1, 0).EntireRow.Insert Set rngCopyTo = wksCopyTo.Cells(Rows.Count, "A").End(xlUp).Offset(2, 0) rngFound.EntireRow.Copy rngCopyTo End If End If 'End If Next wksCopyFrom txtFind.Text = "" Sheets("Search_Add").Activate End Sub |
Problem Pasting entire row.
Thanks for your quick reply Tom. I still can't seem to get this to work.
Any more ideas? Did you notice the two lines that are commented out? -Mark "Tom Ogilvy" wrote: EntireRow should copy the EntireRow. I have never seen it fail: set rngFound = Range("F13") ? rngfound.Address $F$13 ? rngFound.entireRow.Address $13:$13 -- Regards, Tom Ogilvy "Mark Cover" wrote in message ... I am having a problem pasting all of the row in sheet1. It pastes the row starting with the cell that is found and everything to the right, but nothing to the left. If anyone can help that would be nice. Here is the code. Thanks -mark Private Sub cmdFind_Click() Dim wksCopyFrom As Worksheet Dim wksCopyTo As Worksheet Dim rngToSearch As Range Dim rngFound As Range Dim rngCopyTo As Range Set wksCopyTo = Sheets("Search_Add") For Each wksCopyFrom In Worksheets If wksCopyFrom.Name < wksCopyTo.Name And _ wksCopyFrom.Name < "Search_Add" Then 'sheets you don't want searched Set rngToSearch = wksCopyFrom.Cells Set rngFound = rngToSearch.Find(txtFind.Text, , xlValues, LookAt:=xlPart) If Not rngFound Is Nothing Then 'If rngCopyTo.Offset.Value < "" Then 'rngFound.Offset(1, 0).EntireRow.Insert Set rngCopyTo = wksCopyTo.Cells(Rows.Count, "A").End(xlUp).Offset(2, 0) rngFound.EntireRow.Copy rngCopyTo End If End If 'End If Next wksCopyFrom txtFind.Text = "" Sheets("Search_Add").Activate End Sub |
Problem Pasting entire row.
I ran your code and it worked fine for me. The whole row was copied.
Maybe you are not copying what you think you are copying. -- Regards, Tom Ogilvy "Mark Cover" wrote in message ... Thanks for your quick reply Tom. I still can't seem to get this to work. Any more ideas? Did you notice the two lines that are commented out? -Mark "Tom Ogilvy" wrote: EntireRow should copy the EntireRow. I have never seen it fail: set rngFound = Range("F13") ? rngfound.Address $F$13 ? rngFound.entireRow.Address $13:$13 -- Regards, Tom Ogilvy "Mark Cover" wrote in message ... I am having a problem pasting all of the row in sheet1. It pastes the row starting with the cell that is found and everything to the right, but nothing to the left. If anyone can help that would be nice. Here is the code. Thanks -mark Private Sub cmdFind_Click() Dim wksCopyFrom As Worksheet Dim wksCopyTo As Worksheet Dim rngToSearch As Range Dim rngFound As Range Dim rngCopyTo As Range Set wksCopyTo = Sheets("Search_Add") For Each wksCopyFrom In Worksheets If wksCopyFrom.Name < wksCopyTo.Name And _ wksCopyFrom.Name < "Search_Add" Then 'sheets you don't want searched Set rngToSearch = wksCopyFrom.Cells Set rngFound = rngToSearch.Find(txtFind.Text, , xlValues, LookAt:=xlPart) If Not rngFound Is Nothing Then 'If rngCopyTo.Offset.Value < "" Then 'rngFound.Offset(1, 0).EntireRow.Insert Set rngCopyTo = wksCopyTo.Cells(Rows.Count, "A").End(xlUp).Offset(2, 0) rngFound.EntireRow.Copy rngCopyTo End If End If 'End If Next wksCopyFrom txtFind.Text = "" Sheets("Search_Add").Activate End Sub |
Problem Pasting entire row.
Tom, just to let you know that the entire row is pasting, it was my error.
Thanks for your help. "Mark Cover" wrote: Thanks for your quick reply Tom. I still can't seem to get this to work. Any more ideas? Did you notice the two lines that are commented out? -Mark "Tom Ogilvy" wrote: EntireRow should copy the EntireRow. I have never seen it fail: set rngFound = Range("F13") ? rngfound.Address $F$13 ? rngFound.entireRow.Address $13:$13 -- Regards, Tom Ogilvy "Mark Cover" wrote in message ... I am having a problem pasting all of the row in sheet1. It pastes the row starting with the cell that is found and everything to the right, but nothing to the left. If anyone can help that would be nice. Here is the code. Thanks -mark Private Sub cmdFind_Click() Dim wksCopyFrom As Worksheet Dim wksCopyTo As Worksheet Dim rngToSearch As Range Dim rngFound As Range Dim rngCopyTo As Range Set wksCopyTo = Sheets("Search_Add") For Each wksCopyFrom In Worksheets If wksCopyFrom.Name < wksCopyTo.Name And _ wksCopyFrom.Name < "Search_Add" Then 'sheets you don't want searched Set rngToSearch = wksCopyFrom.Cells Set rngFound = rngToSearch.Find(txtFind.Text, , xlValues, LookAt:=xlPart) If Not rngFound Is Nothing Then 'If rngCopyTo.Offset.Value < "" Then 'rngFound.Offset(1, 0).EntireRow.Insert Set rngCopyTo = wksCopyTo.Cells(Rows.Count, "A").End(xlUp).Offset(2, 0) rngFound.EntireRow.Copy rngCopyTo End If End If 'End If Next wksCopyFrom txtFind.Text = "" Sheets("Search_Add").Activate End Sub |
All times are GMT +1. The time now is 10:29 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com