+ Reply to Thread
Results 1 to 5 of 5

explain use of step 2 in VBA code

  1. #1
    Forum Contributor
    Join Date
    03-13-2013
    Location
    india
    MS-Off Ver
    excel 2010
    Posts
    427

    explain use of step 2 in VBA code

    I could not understand reason behind it, please any budy explain that why use step 2 in that VBA code
    check attachment for more detail
    Attached Files Attached Files

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,658

    Re: explain use of step 2 in VBA code

    Please Login or Register  to view this content.
    Step is -1.


    For example:

    Normally, step is +1
    (for example For i = 1 to 6)
    but you can change it.

    If you want step 2, 3, or other you will use: For i = 1 to 6 Step 2

    If you want go backwards, as in your case, and go from last row (Range("B65535").End(xlUp).Row) to 2nd row (To 2) then you need to use Step -1

  3. #3
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,528

    Re: explain use of step 2 in VBA code

    I assume you mean this line of code:
    Please Login or Register  to view this content.
    What it's doing is finding the last populated row and then looping through from that number down to 2 in increments of 1.

    So in this example the first run of the loop will concentrate on row 58. The next loop will be row 57, then 56 etc until it gets to row 2.

    Does that help make sense of it?

    BSB

  4. #4
    Forum Contributor
    Join Date
    03-13-2013
    Location
    india
    MS-Off Ver
    excel 2010
    Posts
    427

    Re: explain use of step 2 in VBA code

    thanks , now my problem is solve , you understand my problem appropriatly, i mistakenly done mistake when asking question

  5. #5
    Forum Contributor
    Join Date
    03-13-2013
    Location
    india
    MS-Off Ver
    excel 2010
    Posts
    427

    Re: explain use of step 2 in VBA code

    thanks for explanation

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA Code works by step by step, doesn't work by running
    By lucasar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2016, 06:33 AM
  2. Explain VBA Code
    By love2waltz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-28-2015, 12:40 PM
  3. Can some one explain what this part of the code is actually doing?
    By Jenkins27 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-02-2015, 07:12 PM
  4. Explain code
    By josros60 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-04-2014, 12:33 AM
  5. Can some one explain this code for me ?
    By chriskingkiller in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-10-2013, 02:14 PM
  6. Can some one explain this code for me ?
    By chriskingkiller in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-10-2013, 12:41 AM
  7. Help Explain this Code
    By khalid79m in forum Excel General
    Replies: 1
    Last Post: 11-27-2008, 06:09 AM

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