Macro: Given row with text "x" copy specific cells from that row to a new sheet

Jat90

New Member
Joined
Jun 8, 2015
Messages
4
After browsing the web, I've managed to find a macro to help me with the above task. Only problem is that it copies over the formula as well. I'm having difficulty in finding away for it to copy and paste special values. Can anyone suggest a tweak in the below code?

Sub CreateOrder()
Dim cell As Range
Dim rngDest As Range
Dim i As Long
Dim arrColsToCopy

arrColsToCopy = Array(1, 2, 17)
'----For every cell in row P on the STOCK LEVELS ALL sheet----'
Set rngDest = Worksheets("NX").Range("A12")

Application.ScreenUpdating = False

For Each cell In Worksheets("STOCK LEVELS ALL").Range("P4:P5000").Cells

If cell.Value = "ORDER" Then

For i = LBound(arrColsToCopy) To UBound(arrColsToCopy)
With cell.EntireRow
.Cells(arrColsToCopy(i)).Copy rngDest.Offset(0, i)
End With
Next i

Set rngDest = rngDest.Offset(1, 0) 'next destination row

End If

Next cell

Application.ScreenUpdating = True

End Sub

Many thanks,
Jat
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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