Code will not copy full list

Frankietheflyer

New Member
Joined
Nov 17, 2017
Messages
26
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:

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
43,557
Office Version
365
Platform
Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,089,739
Messages
5,410,148
Members
403,298
Latest member
The Noob

This Week's Hot Topics

Top