ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy, paste, transpose depending on variable (https://www.excelbanter.com/excel-programming/425471-copy-paste-transpose-depending-variable.html)

Graeme

Copy, paste, transpose depending on variable
 
Hi,

Hoping for some help to modify the code below.

I have data in Sheet 1, and if column C = "Trigger", I need to copy the
cells in that row from columns D thru P. Sheet 2 is the destination, and I
am trying to do a copy, paste values and transpose into column A. And then
delete all zero values from column A of sheet 2.

Thank you, and here is the code:

Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim r As Range
Dim c As Range

Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")

Set r = ws1.Range("C1", ws1.Range("C65536").End(xlUp))
For Each c In r.Cells
If c = "Trigger" Then
'need new code here for the copy / paste part
c.EntireRow.Copy
Destination:=ws2.Range("A65536").End(xlUp).Offset( 1, 0)
End If
Next c

'need code here to delete all the zeros


All times are GMT +1. The time now is 12:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com