Aug 02 2018 11:49 PM
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 first sheet with the same colour in second sheet. I used colours just to understand easy normally there are no colur in columns.
Aug 03 2018 12:14 AM - edited Aug 03 2018 12:15 AM
SolutionSub 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.
Aug 03 2018 12:54 AM
Actually I am not so familiar with the macros, I thought there is gonna be a basic method using formulas.
I tried the apply this macro but I recieved an error as ''subscript out of range''
Aug 03 2018 02:36 AM
Just check the name of the sheets matches the names in the macro.. I might have misspelt it.
Aug 03 2018 12:14 AM - edited Aug 03 2018 12:15 AM
SolutionSub 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.