View Single Post
 
Old 09-09-2020, 08:22 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I'm not sure why it would stop running but it might be because you are comparing a range with a number. Also, I would copy the row to a the first cell rather than to an entire row. Try this
Code:
Sub Transfer_Summary_Detail()
  Dim c As Range, j As Integer
  Dim Source As Worksheet, Target As Worksheet

  Set Source = ActiveWorkbook.Worksheets("Summary")  ' Change worksheet designations as needed
  Set Target = ActiveWorkbook.Worksheets("Sheet1")
  
  j = 4     ' Start copying to 4th row in target sheet
  For Each c In Source.Range("P4:P4000")   ' Do 4000 rows
    If c.Value <> 0 Then
      Source.Rows(c.Row).Copy Target.Range("A" & j)
      j = j + 1
    End If
  Next c
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote