copy to vba

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
 
You are welcome.

Once you have come up with a plan with what to do with those values, let us know if you you run into any issues programming it into your code.
 
Upvote 0

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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