Thursday 26 October 2017

excel vba - Other method than Select in VBA





x.Worksheets("Sheet1").Activate
Range("A65536").Select

ActiveCell.End(xlUp).Select
lastrow = ActiveCell.Row

Range("A2:A" & lastrow).Copy
y.Worksheets("Sheet1").Range("a65536").End(xlUp).Offset(1, 0)
Range("B2:B"
& lastrow).Copy y.Worksheets("Sheet1").Range("b65536").End(xlUp).Offset(1,
0)



I have
read several places that using select is not recommended for copy pasting, and how can
one do it without select?


itemprop="text">
class="normal">Answer



As an
exact analog to your code:



lastRow
=
x.worksheets("Sheet1").range("A65536").end(xlup).row


Added
because of comment recommending better
practices:




with
x.worksheets("Sheet1")
lastRow = .Cells(.Rows.Count,
1).End(xlup).Row
end with


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...