Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Ali,
Dim rng As Range Dim i As Integer Set rng = Selection For i = 1 To rng.Rows.Count MsgBox "x" & i & " is equal to " & rng.Cells(i).Value Next i You could also use the Application.Inputbox method to get the user to select the cells. HTH, Bernie MS Excel MVP "Ali Baba" wrote in message ... 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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Problem with range | Excel Discussion (Misc queries) | |||
Range problem | Excel Programming | |||
getting value of range problem | Excel Programming | |||
range problem | Excel Programming | |||
Range problem | Excel Programming |