Looping through Values

Yao567

New Member
Joined
Oct 4, 2013
Messages
4
Hi so basically i need to loop through the values xo=-7 and xf = 5
For a graph there need to be 21 grid pts ie 21 values between -7 and 5 and i calculate dx to be .6ish

Basically I just need help putting this into a loop using variables for the numbers so i can change the xo's and xf's etc.
Code:
xo = InputBox("What is xo")
xf = InputBox("What is xf")
GridPts = InputBox("What is the number of GridPts")



Range("A1") = "xo"
ActiveCell.Offset(0, 1) = "xf"
ActiveCell.Offset(0, 2) = "GridPts"
ActiveCell.Offset(0, 3) = "dx"
ActiveCell.Offset(1, 0) = xo
ActiveCell.Offset(1, 1) = xf
ActiveCell.Offset(1, 2) = GridPts
ActiveCell.Offset(1, 3) = Dx(xo, xf, GridPts)
A = Dx(xo, xf, GridPts)

Range("B6") = "xo"
For i = xo To xf
Cells(i + 5, 1) = i
Next i
End Sub

This is what i got but doesnt work:(
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
if xo's value is -7 then you should add 8 first to nullify its effect..

Code:
For i = -7 To 5
    Cells(i + 8, 1) = i
Next i
 
Upvote 0

Forum statistics

Threads
1,214,859
Messages
6,121,963
Members
449,059
Latest member
oculus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top