need help

  • Thread starter Thread starter austanley
  • Start date Start date
A

austanley

Hi,

I have, say, three columns and ten rows data, so totally thirty cell
of data. And some of the data appeared once, twice, three times or eve
four times.
What I need to do is assign a unique number to each row. If the sam
data appeared twice in two rows, these two rows will share the sam
unique number.If the same data appeared three times, these one, two o
three rows will share the same unique number.....
I am not sure if this can be done by VBA, say, if the data siz
increase in the future.
Anyone can help me or give me some hints?
Thanks a lot
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top