Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variable in range
Can a variable be put into a range? If so could somebody tell me wha
is wrong with this code. (Cell B6 hold a numeric value.) Dim x As Range x = Range("B6").Value Rows("1:x").Select Selection.Insert Shift:=xlDown Thank you for the help Morr -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variable in range
Moryy,
In "1:x", you really want the value of x not "x" itself. Also, x should be Dim-ed as an Integer (Long?) and not a Range. Change code to something like the following. Hope this helps. Victor --------------------------------------------- Dim x As Integer ' Range?? Dim sRange as string x = Range("B6").Value sRange = "1" & ":" & cstr(x) Rows(sRange).Select Selection.Insert Shift:=xlDown ---------------------------------------------- "morry " wrote: Can a variable be put into a range? If so could somebody tell me what is wrong with this code. (Cell B6 hold a numeric value.) Dim x As Range x = Range("B6").Value Rows("1:x").Select Selection.Insert Shift:=xlDown Thank you for the help Morry --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Variable in range
Maybe just another option:
Dim x As Long x = Range("B6").Value Rows(1).Resize(x).Insert HTH Dana DeLouis "morry " wrote in message ... Can a variable be put into a range? If so could somebody tell me what is wrong with this code. (Cell B6 hold a numeric value.) Dim x As Range x = Range("B6").Value Rows("1:x").Select Selection.Insert Shift:=xlDown Thank you for the help Morry --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Use Sum() with variable range | Excel Worksheet Functions | |||
Variable Range | Excel Discussion (Misc queries) | |||
How to use a variable for a range | Excel Worksheet Functions | |||
variable range: l just can't get there! | Excel Programming | |||
Problem trying to us a range variable as an array variable | Excel Programming |