ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Rows(arguments)??? (https://www.excelbanter.com/excel-programming/301305-rows-arguments.html)

dabith[_2_]

Rows(arguments)???
 
Hey all

another question

how do I use the Lastrow variable in the Rows argument???

Dim Lastrow As Long
With ActiveSheet
Lastrow = .UsedRange.Rows.Count + .UsedRange.Cells(1).Row - 1

Rows("1:Lastrow").Select
Selection.Copy


Thank

--
Message posted from http://www.ExcelForum.com


Norman Jones

Rows(arguments)???
 
Hi Dabith ,

Change:
Rows("1:Lastrow")
to:
Rows("1:" & LastRow).

Also, you are missing an End With and there is no need to select your range.
Therefore, your code could read :

With ActiveSheet
LastRow = (.UsedRange.Rows.Count + .UsedRange.Cells(1).Row - 1)
End With
Rows("1:" & LastRow).Copy

---
Regards,
Norman



"dabith " wrote in message
...
Hey all

another question

how do I use the Lastrow variable in the Rows argument???

Dim Lastrow As Long
With ActiveSheet
Lastrow = .UsedRange.Rows.Count + .UsedRange.Cells(1).Row - 1

Rows("1:Lastrow").Select
Selection.Copy


Thanks


---
Message posted from http://www.ExcelForum.com/




Leo Heuser[_3_]

Rows(arguments)???
 
Hi

Rows("1:" & Lastrow).Select

--
Best Regards
Leo Heuser

Followup to newsgroup only please.

"dabith " skrev i en meddelelse
...
Hey all

another question

how do I use the Lastrow variable in the Rows argument???

Dim Lastrow As Long
With ActiveSheet
Lastrow = .UsedRange.Rows.Count + .UsedRange.Cells(1).Row - 1

Rows("1:Lastrow").Select
Selection.Copy


Thanks


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 04:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com