Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
J@Y J@Y is offline
external usenet poster
 
Posts: 127
Default Range ("1:7") With Variables?

How would I express Range ("1:7") by replacing the 1 and the 7 with integer
variables?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Range ("1:7") With Variables?

One simple way (I'm sure other people will present other ways) is:
Range(var1 & ":" & var2)

"J@Y" wrote:

How would I express Range ("1:7") by replacing the 1 and the 7 with integer
variables?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Range ("1:7") With Variables?

try
v1 = 2
v2 = 6
Rows(v1 & ":" & v2).copy

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"J@Y" wrote in message
...
How would I express Range ("1:7") by replacing the 1 and the 7 with
integer
variables?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Range ("1:7") With Variables?

This demonstrates another way to do this with Excel objects:

Option Explicit

Public Sub RowSelect(WS As Worksheet, intRow1 As Integer, intRow2 As Integer)
Dim rngTest As Range
With WS
Set rngTest = .Range(.Rows(intRow1), .Rows(intRow2))
End With
rngTest.Select
End Sub

Public Sub TestRowSelect()
RowSelect WS:=ThisWorkbook.Worksheets(1), intRow1:=1, intRow2:=7
End Sub

Bob

"J@Y" wrote:

How would I express Range ("1:7") by replacing the 1 and the 7 with integer
variables?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default Range ("1:7") With Variables?

My preference is to avoid strings if possible.

Sub Demo()
Dim r1 As Long
Dim r2 As Long

r1 = 1
r2 = 7
Rows(r1).Resize(r2 - r1 + 1).Select
End Sub

--
Dana DeLouis


"J@Y" wrote in message
...
How would I express Range ("1:7") by replacing the 1 and the 7 with
integer
variables?



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Read ".dll" files, the Macro "work flow" and the actual values of the variables when Macro is running [email protected] Excel Programming 5 May 16th 07 08:18 PM
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" Luc[_3_] Excel Programming 2 September 28th 05 08:37 PM
Using "Cells" to write "Range("A:A,H:H").Select" Trip Ives[_2_] Excel Programming 3 June 5th 04 03:13 PM


All times are GMT +1. The time now is 01:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"