+ Reply to Thread
Results 1 to 5 of 5

using for loop to replace if-then-else

  1. #1
    Registered User
    Join Date
    01-27-2010
    Location
    prague
    MS-Off Ver
    Excel 2010
    Posts
    52

    using for loop to replace if-then-else

    Hi,

    I have written the following:

    Please Login or Register  to view this content.
    This goes on for many more lines. Can someone pls show me how this can be converted to a for loop instead?

    Thanks for any help.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: using for loop to replace if-then-else

    Perhaps.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    01-27-2010
    Location
    prague
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: using for loop to replace if-then-else

    Norie,

    Thanks, that worked perfectly. I have some questions to ask you about your code.

    1. what does the "\" mean in the line
    Please Login or Register  to view this content.
    2. what does this segment
    Please Login or Register  to view this content.
    do?

    Thanks.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: using for loop to replace if-then-else

    1. <dividend>\<divisor> is the Integer Division operator, it returns the no of times the divisor can divide the dividend ignoring the remainder.

    Make sense?

    How about an example?

    5\4 returns 1

    9\4 returns 2

    13\4 returns 3

    and so on.

    We use it to get the no of columns we need to add to the range based on lastcolumn.

    2 This will rerturn Columns(6), Columns(10), Columns(14) etc based on what I is.
    Please Login or Register  to view this content.
    So if I was 2 we first add Columns(6) to the final range, then we add Columns(10).

    Any use?

  5. #5
    Registered User
    Join Date
    01-27-2010
    Location
    prague
    MS-Off Ver
    Excel 2010
    Posts
    52

    Re: using for loop to replace if-then-else

    Thanks for the explanation! Got it now =)

+ 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 Find and replace loop help needed
    By susanbarbour in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-13-2012, 08:43 AM
  2. Excel 2007 : Find and replace loop
    By chrisrabkin in forum Excel General
    Replies: 1
    Last Post: 10-18-2011, 05:58 PM
  3. Find and replace Loop Error
    By fengfeng in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-24-2009, 03:57 PM
  4. [SOLVED] Msg Box on each Loop to Replace text
    By Ricky Pang in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-10-2006, 06:50 PM
  5. Replace using Do loop
    By Dave B in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-29-2005, 03:40 PM

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