Code will not copy full list

Frankietheflyer

New Member
Joined
Nov 17, 2017
Messages
30
Hi

The Code below looks at a dynamic list of information in a worksheet "Teams & Runners Data Form Entry" and should copy all the information in Columns B:E and paste it into the sheet "Team List" columns A:D.

However! It currently only copies 10 of the 18 rows in the "Teams & Runners Data Form Entry" sheet (11 counting the header). Column B in the "Teams & Runners Data Form Entry" sheet is full with no blanks although columns D and E do have some blank cells in them but never in both together on the same row.

I've run a "=COUNTA(B:B)" in the "Teams & Runners Data Form Entry" sheet and it comes up with a count of 18.

An ideas why the code is not copying the last few rows please?


<strike>
</strike>
Code:
[FONT=Verdana]Sub LoadTeamList()[/FONT]
[FONT=Verdana]Application.ScreenUpdating = False[/FONT]
[FONT=Verdana]Dim wb As Workbook
Dim Found As Range[/FONT]
[FONT=Verdana]With Sheets("Team List")[/FONT]
[FONT=Verdana].Range("A:D").ClearContents[/FONT]
[FONT=Verdana]    Set destRng = .Range("A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
    
LastRow = Sheets("Teams & Runners Data Form Entry").Range("B1:B" & Rows.Count).End(xlUp).Row
    Sheets("Teams & Runners Data Form Entry").Range("B1:E1" & LastRow).Copy Destination:=destRng
    
        .Columns("A:D").AutoFit
        
     Application.ScreenUpdating = True
     
     End With[/FONT]
[FONT=Verdana]End Sub
[/FONT]


Thanks

Frankie
 
Last edited:

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
First, your code clears columns A:D in 'Team List' so that code you have to set destRng will always be A1 so that line would be simpler as
Code:
Set destRng = .Range("A1")

In relation to your problem, try making these two changes to your code.

Code:
<del>LastRow = Sheets("Teams & Runners Data Form Entry").Range("B1:B" & Rows.Count).End(xlUp).Row</del>
LastRow = Sheets("Teams & Runners Data Form Entry").Range("B" & Rows.Count).End(xlUp).Row
<del>Sheets("Teams & Runners Data Form Entry").Range("B1:E1" & LastRow).Copy Destination:=destRng</del>
Sheets("Teams & Runners Data Form Entry").Range("B1:E" & LastRow).Copy Destination:=destRng
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,438
Members
448,897
Latest member
dukenia71

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