Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can we change the increment of "i" ?

Status
Not open for further replies.

yliew

Civil/Environmental
Jan 16, 2002
19
AU
Dear all,

I am new in VBA for Excel and currently writing some procedures for my research. The following is a simple code which I wrote but I wish to extend it's capability:
_____________
Sub generatedata()

Max_displacement = InputBox("Enter Maximum Displacement: ")
For i = 0 To Max_displacement
Range("B1") = i
Range("B1").Copy _
Range("B1").Offset(i + 4, -1)
Range("B2").Select
Selection.Copy
Range("B1").Offset(i + 4, 0).Select
Selection.PasteSpecial Paste:=xlValues
Next i

End Sub
______________

As you can see, this procedure copy the data from cell B1 and B2(contains formula which changes with B1) and paste it to two column of cells. However, the "i" value only increase by 1 everytime. I would like it to increase by 0.1 everytime up to the Max_displacement. Are there any special command I can use or I should use a counter.

Thanks!

Regards,
YEN
 
Replies continue below

Recommended for you

Simply use
For i=0 to Max_displacement step 0.1
and replace i with 10*i in the offsets.
prex
motori@xcalcsREMOVE.com
Online tools for structural design
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top