Not finding last row - copy and pasted to last row

thedeadzeds

Active Member
Joined
Aug 16, 2011
Messages
361
Office Version
  1. 365
Platform
  1. Windows
Hi Guys,

I'm trying to copy and past data from the 'Sort Tab' to the 'ScoreCard' tab last row. For some reason when using the below it pastes the data to row 56? Can someone please help?

Thanks


VBA Code:
Sub Core()

If MsgBox("Are you sure you want to run VBA?", vbYesNo) = vbNo Then Exit Sub

Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sort") '<== Sheet that has raw data
Dim LRow As Long, Found As Range
Dim Lastrow As String
Dim Lastrow2 As String
Lastrow = Sheets("Overall Summary").Cells(Rows.Count, "A").End(xlUp).Row


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'Site2
   Sheets("Sort").Select
    ActiveSheet.ListObjects("ScoreCard").Range.AutoFilter Field:=5, Criteria1:= _
        "<>"
Set Found = ws.Range("L1:W1").Find("Site2") '<== Header name to search for"
If Not Found Is Nothing Then
LRow = ws.Cells(ws.Rows.Count, Found.Column).End(xlUp).Row
ws.Range(ws.Cells(2, Found.Column), ws.Cells(LRow, Found.Column)).Copy
Sheets("ScoreCard").Range("A" & Lastrow + 1).PasteSpecial xlPasteValues '<== Sheet to paste data
End If

ws.Activate
ActiveSheet.Select

End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
66,086
Office Version
  1. 365
Platform
  1. Windows
You are calculating the last row based on data in the "Overall Summary" sheet, rather than the "ScoreCard" sheet.
 
Solution

thedeadzeds

Active Member
Joined
Aug 16, 2011
Messages
361
Office Version
  1. 365
Platform
  1. Windows
what a donut, thanks again Fluff, I appreciate your help as always
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
66,086
Office Version
  1. 365
Platform
  1. Windows
Glad to help & thanks for the feedback.
 

Forum statistics

Threads
1,148,424
Messages
5,746,597
Members
424,032
Latest member
pochie2741

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
Top