+ Reply to Thread
Results 1 to 3 of 3

need help

  1. #1
    Registered User
    Join Date
    06-29-2006
    Posts
    2

    need help

    Hi,

    I have, say, three columns and ten rows data, so totally thirty cells of data. And some of the data appeared once, twice, three times or even four times.
    What I need to do is assign a unique number to each row. If the same data appeared twice in two rows, these two rows will share the same unique number.If the same data appeared three times, these one, two or three rows will share the same unique number.....
    I am not sure if this can be done by VBA, say, if the data size increase in the future.
    Anyone can help me or give me some hints?
    Thanks a lot!

  2. #2
    Scott
    Guest

    RE: need help

    You could just loop over your cells and have it count the number of things
    that you're looking for in each row. If you set up a loop using two
    variables, let's say i and j you could have something like

    for i = 1 to 10
    for j = 1 to 3
    'your code here
    next j
    next i

    where it would look over the data going (in this case rows then columns).
    You could then do whatever you want by using an if statement in the middle,
    or just using an increment. It's hard to tell what exactly you're looking
    for, but this might give you an idea of something to try. And instead of 1
    to 10, you could always change it to something like 1 to
    excel.worksheetfunction.counta(rows(1)) or something so that it will expand
    as your data expands.

    Cheers,

    Scott



    "austanley" wrote:

    >
    > Hi,
    >
    > I have, say, three columns and ten rows data, so totally thirty cells
    > of data. And some of the data appeared once, twice, three times or even
    > four times.
    > What I need to do is assign a unique number to each row. If the same
    > data appeared twice in two rows, these two rows will share the same
    > unique number.If the same data appeared three times, these one, two or
    > three rows will share the same unique number.....
    > I am not sure if this can be done by VBA, say, if the data size
    > increase in the future.
    > Anyone can help me or give me some hints?
    > Thanks a lot!
    >
    >
    > --
    > austanley
    > ------------------------------------------------------------------------
    > austanley's Profile: http://www.excelforum.com/member.php...o&userid=35921
    > View this thread: http://www.excelforum.com/showthread...hreadid=569339
    >
    >


  3. #3
    Scott
    Guest

    RE: need help

    You could just loop over your cells and have it count the number of things
    that you're looking for in each row. If you set up a loop using two
    variables, let's say i and j you could have something like

    for i = 1 to 10
    for j = 1 to 3
    'your code here
    next j
    next i

    where it would look over the data going (in this case rows then columns).
    You could then do whatever you want by using an if statement in the middle,
    or just using an increment. It's hard to tell what exactly you're looking
    for, but this might give you an idea of something to try. And instead of 1
    to 10, you could always change it to something like 1 to
    excel.worksheetfunction.counta(rows(1)) or something so that it will expand
    as your data expands.

    Cheers,

    Scott



    "austanley" wrote:

    >
    > Hi,
    >
    > I have, say, three columns and ten rows data, so totally thirty cells
    > of data. And some of the data appeared once, twice, three times or even
    > four times.
    > What I need to do is assign a unique number to each row. If the same
    > data appeared twice in two rows, these two rows will share the same
    > unique number.If the same data appeared three times, these one, two or
    > three rows will share the same unique number.....
    > I am not sure if this can be done by VBA, say, if the data size
    > increase in the future.
    > Anyone can help me or give me some hints?
    > Thanks a lot!
    >
    >
    > --
    > austanley
    > ------------------------------------------------------------------------
    > austanley's Profile: http://www.excelforum.com/member.php...o&userid=35921
    > View this thread: http://www.excelforum.com/showthread...hreadid=569339
    >
    >


+ 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