ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA Code for selecting row (https://www.excelbanter.com/excel-discussion-misc-queries/30032-vba-code-selecting-row.html)

[email protected]

VBA Code for selecting row
 
Ok I know how to write the code for selecting a row. Here is an example:
Rows("8:27").Select

What if instead of the number i want to use vairables such as:
Rows("x:y").Select

Can anyone tell me how to do this? If you can please email



Ron de Bruin

Try this

x = 3
y = 10
Rows(x & ":" & y).Select


--
Regards Ron de Bruin
http://www.rondebruin.nl


" wrote in message
...
Ok I know how to write the code for selecting a row. Here is an example:
Rows("8:27").Select

What if instead of the number i want to use vairables such as:
Rows("x:y").Select

Can anyone tell me how to do this? If you can please email





Dana DeLouis

Just some other options:

Sub Demo()
Dim x, y
x = 3
y = 10
Range(Rows(x), Rows(y)).Select
' or
Rows(x).Resize(y - x + 1).Select
End Sub

--
Dana DeLouis
Win XP & Office 2003


" wrote
in message ...
Ok I know how to write the code for selecting a row. Here is an example:
Rows("8:27").Select

What if instead of the number i want to use vairables such as:
Rows("x:y").Select

Can anyone tell me how to do this? If you can please email






All times are GMT +1. The time now is 01:43 PM.

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