View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
pvictor pvictor is offline
external usenet poster
 
Posts: 1
Default 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/