Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Change the row while getting pasted from 1st row to fifth row

Here I am finding the last column in the sheet and copy pasting a column from one sheet to another.
It prints in the lcolumns but in 1st row i need to copy and gets pasted from 5th row.

Function Coletter(lngCol As Long) As String
    Dim vArr
    vArr = Split(Cells(1, lngCol).Address(True, False), "$")(0)
    Coletter = vArr
End Function

Sub Run_Macro()
     Dim lColumn As long
     Dim lColumns As long
     'Finding last column
     lColumn = Worksheets("Program Matrix").Cells(5, Columns.Count).End(xlToLeft).Column
  
     lColumns = lColumn + 1
     MsgBox (lColumns)    

     Sheets("Output").Columns(60).Copy Destination:=Sheets("Sheet 1").Columns(lColumns)

End Sub

Sheets("Sheet 1").Columns(lColumns)
Here lcolumns display the column number. But i need to get it printed from 5th row of the same column number(while it gets pasted from 1st row). How can i paste the same from 5th row.
Can someone pls guide in this.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can’t paste a whole column to row 5 (because it won’t fit), so you need to shrink the copy area a little…

With Sheets("Output").Columns(60)
    .Resize(.Rows.Count-5).Copy Destination:=Sheets("Sheet 1").Cells(5, lColumns)
End With
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading