+ Reply to Thread
Results 1 to 6 of 6

using the mod function to alternate rows

  1. #1
    Registered User
    Join Date
    03-22-2009
    Location
    wichita, kansas
    MS-Off Ver
    Excel 2007
    Posts
    15

    using the mod function to alternate rows

    new problem:

    imagine your data set:

    1
    2
    3
    4
    5
    6

    i want to have

    -1
    2
    -3
    4
    -5
    6

    i'm using the mod function but am unsure how to put it into the for each loop.

    i'm guessing its something like
    Please Login or Register  to view this content.
    i know thats probably not the correct code at all, but i'm jsut trying to learn all the excel operators. i've only used VB.
    Last edited by withy; 03-24-2009 at 05:48 AM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: using the mod function to alternate rows

    I'm not really clear what you're trying to do ... perhaps something along the lines of:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-22-2009
    Location
    wichita, kansas
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: using the mod function to alternate rows

    well, that worked perfectly. ignore the coding, that was jsut my little experiment to try and get it to work before i asked for help.

    let me know though..... would it have worked using the for each loop and a counter?

  4. #4
    Registered User
    Join Date
    03-22-2009
    Location
    wichita, kansas
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: using the mod function to alternate rows

    EDIT: ok, the code worked great but only for sequential values. the spreadsheet is organizing the numbers then multipying by -1. i apologize but i should have been more clear. the numbers are random.

    546
    654
    871
    1235
    12
    5
    54

    and i need:
    -546
    654
    -871
    1235
    -12
    5
    -54

    make sense? and the code that i provided was my attempt at getting the mod function to work. see i'm pretty new at this and was jsut trying to get the mod function to work before i asked for help
    Last edited by withy; 03-23-2009 at 01:35 PM.

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: using the mod function to alternate rows

    Perhaps:

    Please Login or Register  to view this content.
    A "negative" row is deemed as one that equates to the Odd/Even status of the first row in the range being processed... ie if first row is 2 then Even rows should be set to opposite sign, if first row is 1 then Odd rows should be set to opposite sign.

  6. #6
    Registered User
    Join Date
    03-22-2009
    Location
    wichita, kansas
    MS-Off Ver
    Excel 2007
    Posts
    15

    Re: using the mod function to alternate rows

    well that seamed to have worked. thanks man. your pretty damn good at this.

+ 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