Thread: Range problem
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ali Baba Ali Baba is offline
external usenet poster
 
Posts: 16
Default Range problem

I am writting a function and the user needs to select a range for the x
values. If the user selected, say, the range "A1:A2" then

x1 = rng(1)
x2 = rng(2)

If the range "B2:B4", then
x1 = rng(1)
x2 = rng(2)
x3 = rng(3)

I wrote this code to carry out the above task

NoOfRowsSelected = rng.Rows.Count

For i = 1 To NoOfRowsSelected
namex = "x" & i
namex = rng(i).value
Next i

The code is only working for i = 3. In other words, it does not give the
right values for x1, x2, x4, .....

Can anybody help?