How can I modify
XLApp.Range("A1:K1" & LastRow).Copy
if I want to copy the A1:K1 untill the last row there is data in one of the cells in the selected area . Sorry for my poor English.
How can I modify
XLApp.Range("A1:K1" & LastRow).Copy
if I want to copy the A1:K1 untill the last row there is data in one of the cells in the selected area . Sorry for my poor English.
LastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, 1).End(xlUp).Row
will give you the last row in column no 1 ("A"). For last row in column k, you need to use 11 in place of 1.
The code below shows a generic way to do that:
Range(Range("A1", Range("A1").End(xlToRight)), Range("A1", Range("A1").End(xlDown))).Rows.Count
you can change the A1 reference to other if you want. The codes copy a range the starts from A1 to right and from right to down.