Hello,
I am currently working on copying the data from excel table to paste in Outlook email, but my main problem is I wanted to copy the table dynamically because my last data in the table is dependent on what it needs to capture (For example the last column may be until to H, or until to K, it depends on the data captured, as well as the last row)
I am not pro or good in VBA, so Im not sure if Im doing this right. Hope you can help
So my code is this:
Sub CopyTable
Dim lastrow as integer
Dim lastcol as integer
Dim ws as worksheet
set ws = Thisworkbook.Sheets("Sheet1")
lastrow = ws.Cells(ws.Rows.Count, "B").End(xlUp).Row
lastcol = ws.Cells(2, ws.Columns.Count).End(xlToLeft).Column
ws.Range(lastcol & lastrow).Copy
End Sub
and my First column is no blank. So the example table can be like this:
I am currently working on copying the data from excel table to paste in Outlook email, but my main problem is I wanted to copy the table dynamically because my last data in the table is dependent on what it needs to capture (For example the last column may be until to H, or until to K, it depends on the data captured, as well as the last row)
I am not pro or good in VBA, so Im not sure if Im doing this right. Hope you can help
So my code is this:
Sub CopyTable
Dim lastrow as integer
Dim lastcol as integer
Dim ws as worksheet
set ws = Thisworkbook.Sheets("Sheet1")
lastrow = ws.Cells(ws.Rows.Count, "B").End(xlUp).Row
lastcol = ws.Cells(2, ws.Columns.Count).End(xlToLeft).Column
ws.Range(lastcol & lastrow).Copy
End Sub
and my First column is no blank. So the example table can be like this: