Can we change the increment of "i" ?
Can we change the increment of "i" ?
(OP)
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
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





RE: Can we change the increment of "i" ?
For i=0 to Max_displacement step 0.1
and replace i with 10*i in the offsets.
prex
motori@xcalcsREMOVE.com
http://www.xcalcs.com
Online tools for structural design