rngFoundAll.EntireRow.Copy Destination:=rngPaste

micko1

Board Regular
Joined
Feb 10, 2010
Messages
80
Need help with sintax. I have used the attached code to cut and paste entire row to new sheet. Problem is it does not paste special eg formulas, is it possible to add code so all formats and formulas copy across.
Thanks for looking.

Mick

Private Sub Move_Compliant_Click()
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim rngPaste As Range
Dim strFirstAddress As String
Set rngPaste = Sheets("Regional Contractors").Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)
Set rngToSearch = ActiveSheet.Columns("O")
Set rngFound = rngToSearch.Find(What:="Compliant", _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "There are no items to move."
Else
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress
rngFoundAll.EntireRow.Copy Destination:=rngPaste
rngFoundAll.EntireRow.Delete 'Optional to Delete
End If
End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Maybe like this

Code:
rngFoundAll.EntireRow.Copy
rngPaste.PasteSpecial Paste:=xlPasteFormats
rngFoundAll.EntireRow.Copy Destination:=rngPaste
 
Upvote 0
Firstly, Thanks heaps guys for your help. Not sure why but the macro moves the rows from one spreadsheet to the other but does not always move the formulas and conditional formating, Not sure what is going on. The purpose of the workbook is to move listed contractors from sheet to sheet depending on their compliance. If they are compliant they live on the front page, when and if they become non compliant their details are moved onto the second sheet called "NonCompliant", if they then become compliant they obviosly move back onto the main list. I guess you get the drift. Is it possible to send you a sample of the workbook for you to look at for me.
Thanks again for your help.

Mick
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,865
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top