Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Range ("1:7") With Variables?
How would I express Range ("1:7") by replacing the 1 and the 7 with integer
variables? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Read ".dll" files, the Macro "work flow" and the actual values of the variables when Macro is running | Excel Programming | |||
use variable in Workbooks("book1").Worksheets("sheet1").Range("a1" | Excel Programming | |||
Using "Cells" to write "Range("A:A,H:H").Select" | Excel Programming |