filmov
tv
VBA Paste multiple columns array on sheet
Показать описание
Paste a multiple columns array on a range of cells.
Code:
Sub paste_multiple_columns_array_on_sheet()
Dim ws_sheet As Worksheet
Dim ws_sheet2 As Worksheet
Dim lastrow As Long
Dim lastcolumn As Long
Dim array_data() As Variant
'identify worksheets
Set ws_sheet = Worksheets(2)
Set ws_sheet2 = Worksheets(1)
'find table's limits
lastrow = ws_sheet.Cells(Rows.Count, 1).End(xlUp).Row
lastcolumn = ws_sheet.Cells(1, Columns.Count).End(xlToLeft).Column
'save table in array
array_data = ws_sheet.Range(ws_sheet.Cells(1, 1), ws_sheet.Cells(lastrow, lastcolumn))
'paste array on another sheet
ws_sheet2.Range(ws_sheet2.Cells(4, 1), ws_sheet2.Cells(UBound(array_data) + 3, UBound(array_data, 2))) = array_data
End Sub
-------------------------------
NEED HELP?
-------------------------------
Leave a comment with your questions, issues or projetcs and I will try to answer with a video.
-------------------------------
THANK YOU
-------------------------------
For watching my videos,
Your shares
And your comments!
Code:
Sub paste_multiple_columns_array_on_sheet()
Dim ws_sheet As Worksheet
Dim ws_sheet2 As Worksheet
Dim lastrow As Long
Dim lastcolumn As Long
Dim array_data() As Variant
'identify worksheets
Set ws_sheet = Worksheets(2)
Set ws_sheet2 = Worksheets(1)
'find table's limits
lastrow = ws_sheet.Cells(Rows.Count, 1).End(xlUp).Row
lastcolumn = ws_sheet.Cells(1, Columns.Count).End(xlToLeft).Column
'save table in array
array_data = ws_sheet.Range(ws_sheet.Cells(1, 1), ws_sheet.Cells(lastrow, lastcolumn))
'paste array on another sheet
ws_sheet2.Range(ws_sheet2.Cells(4, 1), ws_sheet2.Cells(UBound(array_data) + 3, UBound(array_data, 2))) = array_data
End Sub
-------------------------------
NEED HELP?
-------------------------------
Leave a comment with your questions, issues or projetcs and I will try to answer with a video.
-------------------------------
THANK YOU
-------------------------------
For watching my videos,
Your shares
And your comments!