+ Reply to Thread
Results 1 to 4 of 4

For-Next loop in 0.1 incriments

  1. #1
    Registered User
    Join Date
    11-20-2009
    Location
    south wales
    MS-Off Ver
    Excel 2007
    Posts
    14

    For-Next loop in 0.1 incriments

    hi, i currently have an excel spreadsheet in which im looking to automate some calculations that need repeating with a different value each time until the answer matches another value.

    ive picked up excel 2007 VBA programming for dummies as ive never used visual basic and have read up to chapter 10 which outlines loops. the basic example states:

    Please Login or Register  to view this content.
    this gives the values 1, 2, 3 etc in each subsequent column of my excel worksheet.

    what i want however is the values 0.1, 0.2, 0.3 up to 10. ive changed the code to give:

    Please Login or Register  to view this content.
    this gives values 1.4,2.4,3.4 etc and not the values im looking for. i think the problem may be in the activecell line but looking in the book and online i cant see where im going wrong.

    thanks tom

  2. #2
    Registered User
    Join Date
    03-23-2006
    Location
    Smithville, TN
    MS-Off Ver
    2003
    Posts
    12

    Re: For-Next loop in 0.1 incriments

    Try this...

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-20-2009
    Location
    south wales
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: For-Next loop in 0.1 incriments

    ahhh brilliant that works a charm. just looking at visual basic help i can see that round takes the expression to a given number of decimal places but what does VBA refer to? it dosent seem to bring anything up when i click F1(help).

  4. #4
    Registered User
    Join Date
    03-23-2006
    Location
    Smithville, TN
    MS-Off Ver
    2003
    Posts
    12

    Re: For-Next loop in 0.1 incriments

    Quote Originally Posted by mister tom View Post
    what does VBA refer to?
    VBA is the library where the math function is implemented. Sometimes, if you don't state the library or parent, Excel throws an error. You probably didn't need it, but I didn't want to take a chance.

    Also, if there was a Round member of two different libraries available, putting "VBA" in front of the Round member lets the code know exactly which library to get the Round member from.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1