Getting the last fillled column in a sheet1 and copying the data in sheet2 to sheet1

Mikz

I have two sheets.

sheet1 and sheet2.

I have my data in sheet2. The sheet1 already contains data until 4th row.

I would like to copy all the data in sheet2, from row5 to sheet 1 after the 4th row.

I tried the below code. but each time I run the code. it is getting copied randomly in 114 row or sometimes in 1000th row.

here is the code , I am using to copy.

Sub FClookup()
Dim LastRow As Long

    'get last row
    LastRow = Worksheets("Sheet1").Cells(Rows.count, 1).End(xlUp).Row
    Worksheets("Sheet2").Range("A5:W1000").Copy _
    Destination:=Worksheets("Sheet1").Range("A" & LastRow + 1)


End Sub
tk78

The following should do what you're looking for. The code is assuming that Column A in Sheet2 is always filled and will copy all the data from Columns A to D from Sheet2 to the next free Row in Sheet1 (checking column A).

Option Explicit

Sub CopyStuff()

    Dim ws1, ws2 As Worksheet

    Set ws1 = Worksheets("Sheet1")
    Set ws2 = Worksheets("Sheet2")

    ws2.Range("A5:D" & ws2.Range("A5").End(xlDown).Row).Copy
    ws1.Range("A" & ws1.Range("A1").End(xlDown).Row + 1).PasteSpecial xlValues

End Sub

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Copying data based on the headers from Sheet1 to Sheet2

From Dev

Copying data based on the headers from Sheet1 to Sheet2

From Dev

Copying cells from sheet1 to sheet2 if it does not exist in sheet2

From Dev

I need to match Sheet1 Column A to Sheet2 Column A if they match then copy Sheet2 Column B to Sheet1 Column I

From Dev

Copying columns in Excel from sheet1 to sheet2 without having to cut and paste

From Dev

Copying active row of Sheet1 to Sheet2 based on cell condition & avoid duplicates

From Dev

Automatically Copy cells from Sheet2 to Custom column on Sheet1 with rule

From Dev

Refer data from sheet2 to sheet1 dynamically based on date

From Dev

How to update existing data from Sheet1 to Sheet2 using Macro?

From Dev

How to run a macro in sheet1 from sheet2

From Dev

How To copy data from a range in sheet1 to sheet2 5 times until I reach an empty cell?

From Dev

Linq to Excel - only recieving data from last row in sheet1

From Dev

Excel: Trying to consolidate weighted average data from Sheet1 and summarize to Sheet2 when Sheet 1 has variable number of rows

From Dev

Copying 1 column of filtered data to another sheet

From Dev

Run A Macro on Each Sheet Except Sheet1 and Sheet2

From Dev

Need to find the last row in a spreadsheet before copying and pasting data from Sheet 1 to Sheet 2

From Dev

Concatenate 2 cells from Sheet1 to 1 cell Sheet2

From Dev

Excel: how to sum values in sheet2 based on whether a value in sheet1 matches value in sheet2

From Dev

How to iterate through rows in sheet1 given cell value in sheet2 and replace row in sheet1 with row in sheet 2?

From Dev

Create columns in sheet2 depending on number of rows in sheet1 in excel

From Dev

VBA - Check a range in sheet1 for a variable and create a list on sheet2 of each occurence of the variable

From Dev

search all rows and columns in sheet1 for string, copy entire row to sheet2 if found

From Dev

Excel Online - Replicate date from sheet1 columnA to sheet2 columnB

From Dev

How to reflect sheet1's those rows only which contains positive values, into sheet2?

From Dev

excel compare current time value from sheet1 to time value range from sheet2

From Dev

Copy Row if Sheet1 A contains part of Sheet2 C

From Dev

Excel VBA-Find string in sheet2 and copy the this in sheet1

From Dev

Validate if a Prefix in sheet2 has a matching value in sheet1

From Dev

ORDERING columns in sheet2 based on a column in sheet 1 - excel

Related Related

  1. 1

    Copying data based on the headers from Sheet1 to Sheet2

  2. 2

    Copying data based on the headers from Sheet1 to Sheet2

  3. 3

    Copying cells from sheet1 to sheet2 if it does not exist in sheet2

  4. 4

    I need to match Sheet1 Column A to Sheet2 Column A if they match then copy Sheet2 Column B to Sheet1 Column I

  5. 5

    Copying columns in Excel from sheet1 to sheet2 without having to cut and paste

  6. 6

    Copying active row of Sheet1 to Sheet2 based on cell condition & avoid duplicates

  7. 7

    Automatically Copy cells from Sheet2 to Custom column on Sheet1 with rule

  8. 8

    Refer data from sheet2 to sheet1 dynamically based on date

  9. 9

    How to update existing data from Sheet1 to Sheet2 using Macro?

  10. 10

    How to run a macro in sheet1 from sheet2

  11. 11

    How To copy data from a range in sheet1 to sheet2 5 times until I reach an empty cell?

  12. 12

    Linq to Excel - only recieving data from last row in sheet1

  13. 13

    Excel: Trying to consolidate weighted average data from Sheet1 and summarize to Sheet2 when Sheet 1 has variable number of rows

  14. 14

    Copying 1 column of filtered data to another sheet

  15. 15

    Run A Macro on Each Sheet Except Sheet1 and Sheet2

  16. 16

    Need to find the last row in a spreadsheet before copying and pasting data from Sheet 1 to Sheet 2

  17. 17

    Concatenate 2 cells from Sheet1 to 1 cell Sheet2

  18. 18

    Excel: how to sum values in sheet2 based on whether a value in sheet1 matches value in sheet2

  19. 19

    How to iterate through rows in sheet1 given cell value in sheet2 and replace row in sheet1 with row in sheet 2?

  20. 20

    Create columns in sheet2 depending on number of rows in sheet1 in excel

  21. 21

    VBA - Check a range in sheet1 for a variable and create a list on sheet2 of each occurence of the variable

  22. 22

    search all rows and columns in sheet1 for string, copy entire row to sheet2 if found

  23. 23

    Excel Online - Replicate date from sheet1 columnA to sheet2 columnB

  24. 24

    How to reflect sheet1's those rows only which contains positive values, into sheet2?

  25. 25

    excel compare current time value from sheet1 to time value range from sheet2

  26. 26

    Copy Row if Sheet1 A contains part of Sheet2 C

  27. 27

    Excel VBA-Find string in sheet2 and copy the this in sheet1

  28. 28

    Validate if a Prefix in sheet2 has a matching value in sheet1

  29. 29

    ORDERING columns in sheet2 based on a column in sheet 1 - excel

HotTag

Archive