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.
CodePudding user response:
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