ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using variable to select rows (https://www.excelbanter.com/excel-programming/355524-using-variable-select-rows.html)

Jack77

Using variable to select rows
 
What is wrong with this macro? I'm trying to use variable to select rows but
when I execute it I get type mismatch error.

Sub Test()
Dim start As String
Dim end As String
start = 1
end = 2
Rows("start:end").Select
End Sub

In this case it should select rows 1 and 2.

Trevor Shuttleworth

Using variable to select rows
 
Sub Test()
Dim sStart As String
Dim sEnd As String
sStart = 1
sEnd = 2
Rows(sStart & ":" & sEnd).Select
End Sub

Regards

Trevor


"Jack77" wrote in message
...
What is wrong with this macro? I'm trying to use variable to select rows
but
when I execute it I get type mismatch error.

Sub Test()
Dim start As String
Dim end As String
start = 1
end = 2
Rows("start:end").Select
End Sub

In this case it should select rows 1 and 2.





All times are GMT +1. The time now is 11:29 AM.

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