Using variable to select rows

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
Sub Test()
Dim sStart As String
Dim sEnd As String
sStart = 1
sEnd = 2
Rows(sStart & ":" & sEnd).Select
End Sub

Regards

Trevor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top