Variable Syntax Error

specs

New Member
Joined
Oct 26, 2005
Messages
27
Code:
Dim rowStart As Integer
Dim rowEnd As Integer

rowStart = 2
rowEnd = 5

Rows.("rowStart:rowEnd").Select

Can someone help me out with the Rows.("rowStart:rowEnd")
im getting an error for that part.
 

Some videos you may like

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,088
Office Version
  1. 365
Platform
  1. Windows
Does this work?
Code:
Dim rowStart As Integer
Dim rowEnd As Integer

rowStart = 2
rowEnd = 5

Rows(rowStart & ":" & rowEnd).Select
By the way why are you selecting a range? You don't actually need to select/activate ranges etc to work with them.
 

specs

New Member
Joined
Oct 26, 2005
Messages
27
Great it works. Thanks Norie.

By the way why are you selecting a range? You don't actually need to select/activate ranges etc to work with them.

The select is just an example. it supposed to be .Copy
 

Watch MrExcel Video

Forum statistics

Threads
1,119,137
Messages
5,576,300
Members
412,716
Latest member
thviid
Top