×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Can we change the increment of "i" ?

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

RE: Can we change the increment of "i" ?

Simply use
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources