+ Reply to Thread
Results 1 to 12 of 12

How can I mark every other row with a code?

  1. #1
    Registered User
    Join Date
    07-30-2012
    Location
    Great Barrington, MA
    MS-Off Ver
    Excel 2000
    Posts
    4

    How can I mark every other row with a code?

    Every column is marked with a code (<1>begins every cell in the first column, <2> begins every cell in the second column, etc.). I will save my Excel file to text and bring it into a desktop publishing program and use the codes to arrange the information differently.

    When I'm done, each row will be a separate paragraph. I will format my pages with 2 paragraphs per page. It would be easier (there are 2600 rows in this database) if I could tag every other row with a different code. IOW, <1a> for cell A1, <1b> for cell A2, <1a> for cell A3, <1b> for cell A4, etc.

    Right now I'm using Find/Replace and replacing every other <1> code with a <1a> code, but this is very slow. Is there an easy way to do this? Ideally, I'd like to be able to mark every other row within a selected range, not the entire spreadsheet. I'm using Excel 2000.

    Ken Benson
    Last edited by kbenson; 07-31-2012 at 09:32 PM.

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,766

    Re: How can I mark every other row with a code?

    Let me introduce you to the MOD function - it returns the remainder after division. So, if you have a formula like =MOD(number,2), where number is an integer, it will return either 0 or 1, depending on whether number is even or odd. Excel 2000 didn't/doesn't have an EVEN and ODD function, so this is one way of achieving that.

    So, you can put this formula in a cell somewhere,

    =MOD(ROW(),2)

    and when you copy it down it will give you a series of zeros and ones. Applying this to your problem, you could have this formula:

    =IF(MOD(ROW(),2)=1,"<1a>","<1b>")

    which will return <1a> then <1b> to alternate rows.

    Hope this helps.

    Pete

  3. #3
    Forum Contributor BenMiller's Avatar
    Join Date
    12-06-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: How can I mark every other row with a code?

    Going off what Pete_UK said, you can use this formula to drag across columns and down rows too.

    ="<"&COLUMN()&CHAR(MOD(ROW()-1,2)+97)&">"

    or

    ="<"&COLUMN()&CHOOSE(MOD(ROW()-1,2)+1,"a","b")&">"

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: How can I mark every other row with a code?

    @ Pete, Excel does have an ISEVEN and ISODD Function. I believe it dates back to Excel 2000 but am not sure. If the OP wanted to use that instead,

    =IF(ISEVEN(ROW()),"<1b>","<1a>")
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Forum Contributor BenMiller's Avatar
    Join Date
    12-06-2011
    Location
    New Jersey
    MS-Off Ver
    Excel 2010
    Posts
    254

    Re: How can I mark every other row with a code?

    @ ChemistB, I believe it would be necessary to load the ToolPak Add-in in versions earlier than 2007. So, you're both right
    Last edited by BenMiller; 07-31-2012 at 12:09 PM.

  6. #6
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: How can I mark every other row with a code?

    Thanks Ben.

  7. #7
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,766

    Re: How can I mark every other row with a code?

    Yeah, Ben's right - I just checked on an old PC which still has XL2000 installed on it.

    Pete

  8. #8
    Registered User
    Join Date
    07-30-2012
    Location
    Great Barrington, MA
    MS-Off Ver
    Excel 2000
    Posts
    4

    Re: How can I mark every other row with a code?

    This is great! Thank you, Pete!

    Ken

  9. #9
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: How can I mark every other row with a code?

    @ kbenson

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  10. #10
    Registered User
    Join Date
    07-30-2012
    Location
    Great Barrington, MA
    MS-Off Ver
    Excel 2000
    Posts
    4

    Re: How can I mark every other row with a code?

    I got to spend only a few minutes on this before dinner. I wanted to try out the other two solutions and give them some recognition before I marked it solved. I've spent years answering questions in various desktop publishing newsgroups, and I know how frustrating it is when you post a perfectly good solution and get ignored.

    Ken

    ---------- Post added at 09:28 PM ---------- Previous post was at 09:16 PM ----------

    Ben's solution works too, although I don't understand it. Pete's is simpler, and I can see how to change it. When I first posted, I forgot that I'm beginning in the second row, so I really need A2 to be <1a> and A3 to be <1b>, etc.

    ---------- Post added at 09:30 PM ---------- Previous post was at 09:28 PM ----------

    Yes, this doesn't work (probably would if I got the Add-in).

    Ken

  11. #11
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,766

    Re: How can I mark every other row with a code?

    Ken, you can change the =1 to =0 in the middle of my formula to get a different starting value.

    Pete

  12. #12
    Registered User
    Join Date
    07-30-2012
    Location
    Great Barrington, MA
    MS-Off Ver
    Excel 2000
    Posts
    4

    Re: How can I mark every other row with a code?

    Thanks, Pete, that's neater than what I was doing (switching the codes themselves).

    Ken

+ 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