billandrew
Well-known Member
- Joined
- Mar 9, 2014
- Messages
- 743
good evening
trying to copy all values (numbers 1 through 4) in column e to a new appropriate worksheet. For some reason not all data is copied over.
There are many spaces between rows, do not believe this is the reason? Used this code before, no issue in past.
Any help would be appreciated
Code using.
Dim i As Long
Dim lastrow As Long
Dim lastrow2 As Long
Dim sh As string
Sheets("Sheet2A").Activate
Application.ScreenUpdating = False
lastrow = Sheets("Sheet2A").Range("E" & Rows.Count).End(xlUp).Row
For i = 2 To lastrow
If Cells(i, "E").Value <> "" Then
result = Cells(i, "E").Value
Sheets("Sheet2A").Rows(1).Copy Destination:=Sheets(sh).Rows(1)
lastrow2 = Sheets(sh).Cells(Rows.Count, "A").End(xlUp).Row + 1
Rows(i).Copy Destination:=Sheets(sh).Rows(lastrow2)
End If
Next i
Application.ScreenUpdating = True
Exit Sub
End Sub
trying to copy all values (numbers 1 through 4) in column e to a new appropriate worksheet. For some reason not all data is copied over.
There are many spaces between rows, do not believe this is the reason? Used this code before, no issue in past.
Any help would be appreciated
Code using.
Dim i As Long
Dim lastrow As Long
Dim lastrow2 As Long
Dim sh As string
Sheets("Sheet2A").Activate
Application.ScreenUpdating = False
lastrow = Sheets("Sheet2A").Range("E" & Rows.Count).End(xlUp).Row
For i = 2 To lastrow
If Cells(i, "E").Value <> "" Then
result = Cells(i, "E").Value
Sheets("Sheet2A").Rows(1).Copy Destination:=Sheets(sh).Rows(1)
lastrow2 = Sheets(sh).Cells(Rows.Count, "A").End(xlUp).Row + 1
Rows(i).Copy Destination:=Sheets(sh).Rows(lastrow2)
End If
Next i
Application.ScreenUpdating = True
Exit Sub
End Sub