How to copy dynamic range in Excel Sheet using vba
I am trying to make the rang is dynamic in the macro without specifying the last line x.Sheets("SheetName").Range("A2:K1000").Copyin 1000 line I want to change it to dynamic because sometimes I have...
View ArticleAnswer by Plagon for How to copy dynamic range in Excel Sheet using vba
Try this: Sub Test() Dim lRow as Long Dim sht as WorksheetSet sht = x.Sheets("SheetName")lRow = sht.Cells(sht.Rows.Count, 2).End(xlUp).Rowsht.Range("A2:K"& lRow).CopyEnd Sub
View ArticleAnswer by user4039065 for How to copy dynamic range in Excel Sheet using vba
Typically, look for the last row containing a value from the bottom up.with x.Sheets("SheetName") .Range(.cells(2, "A"), .cells(.rows.count, "K").end(xlup)).Copy'paste it somewhereend with
View ArticleAnswer by Vityata for How to copy dynamic range in Excel Sheet using vba
Something like this will do the job:Option ExplicitPublic Sub TestMe() Dim lngLastRow As Long lngLastRow = 150'or come up with a function from here'https://www.rondebruin.nl/win/s9/win005.htm With...
View Article