Forum Discussion

Anıl Adaş's avatar
Anıl Adaş
Brass Contributor
Aug 03, 2018
Solved

PLS HELP How can I fill the columns automatically from another excel sheet?

I don't wanna lose my time with copy-paste. I need to fill an excel sheet automatically from another one but the columns are different.   As you see the photos below, I need to fill the columns in ...
  • Philip West's avatar
    Aug 03, 2018

    Sub copy_paste()

    Dim r As Integer

    r = ThisWorkbook.Sheets("Sheet1").Range("A" & ThisWorkbook.Sheets("Sheet1").Rows.Count).End(xlUp).Row   'get the size of the data

        '=======================COPY/PASTE DATA INTO THE TABLE==========================
        ThisWorkbook.Sheets("Sheet1").Range("C2" & ":" & "C" & r).Copy
        ThisWorkbook.Sheets("Satirlar").Range("E2").PasteSpecial Paste:=xlPasteValues
       
        ThisWorkbook.Sheets("Sheet1").Range("H2" & ":" & "H" & r).Copy
        ThisWorkbook.Sheets("Satirlar").Range("A2").PasteSpecial Paste:=xlPasteValues
       
        ThisWorkbook.Sheets("Sheet1").Range("I2" & ":" & "I" & r).Copy
        ThisWorkbook.Sheets("Satirlar").Range("C2").PasteSpecial Paste:=xlPasteValues
       
        ThisWorkbook.Sheets("Sheet1").Range("J2" & ":" & "J" & r).Copy
        ThisWorkbook.Sheets("Satirlar").Range("D2").PasteSpecial Paste:=xlPasteValues
       
    End Sub

     

    This would do what you want I guess, there are probably neater ways, but if you just want to move everything over in one go then this will get the job done.

Resources