View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
Peter T
 
Posts: n/a
Default Unique identifier

The "values" I suggested adding won't change. To initialise put the row
number as a value in each cell of a (hidden) column. In future events if
there is no value the relative cell maybe something like -

thisrowIDcellInColA = Application.Max(Columns("A")) + 1

But would need to figure something if user copy/pastes the entire row.

Regards,
Peter T

"Steve Barnett" wrote in message
...
I also need to "keep" the unique identifier once it's been set.

The purpose behind this is that I need to copy some data from the
spreadsheet in to a database. There is nothing in the rows of the
spreadsheet that "uniquely" identifies it so there is nothing that I can
hold on to that makes the connection between the row in the spreadsheet

and
the record in the database.

Theory said that, if I could put a unique identifier in each row and, once
set, that identifier didn't change (so I can't use row number) then I had
something I could make the connection with.

I wonder if I could fiddle it with named ranges? Wonder if this would
work... Initially give a cell in every row a "name" (Say row-nnnnn). Then,
when the user inserts rows and copies and pastes stuff around, the named
range shouldn't change - it'll stick with the original cell. Then, when I
close the spreadsheet, I scan down the column with the named ranges,
checking to make sure that every row has a range name (if that's

possible).
If I find a cell without a name, I add one.

Must go and play...

Thanks
Steve




"Peter T" <peter_t@discussions wrote in message
...
Afraid my suggestion about storing values etc doesn't cater for
possibility
of entire row being copied ):-

Peter T

"Peter T" <peter_t@discussions wrote in message
...
Hi Steve,

To cover all the scenarios you mention might be impractical, but for

what
purpose/usage do you need unique row identifiers, in addition to the

fact
you can always read row numbers.

Maybe you could define worksheet level named ranges, these would move

as
you
insert rows though would end up with meaningless names for deleted

ranges
(#REF). Would you want 10k names though (but much better than 10k

comments).

If you were "allowed" to insert an extra column (hidden perhaps)

populate
with row numbers as values. Store the highest number somewhere (a cell

or
named formula). To cater for row inserts & new rows at the end, in

selection
and/or change events check the identifier cell has a value. If not

increment
the stored highest number and place same as the new identifier.

But with the limitations imposed by your client you are a bit strapped!

Regards,
Peter T

"Steve Barnett" wrote in message
...
I have a spreadsheet (Excel 2000) that contains around 10,000 rows. I

now
need to be able to identify each row via a unique identifier, but am
having
trouble working out what to do when new rows are added or when

existing
rows
are copied and paste.

New rows and copied rows should get new unique identifiers, but I can

see
no
way of doing this. Does anyone have any suggestions? There is nothing
unique
about the data that I can hang on to and the "SheetChanged" event

does
not
fire for inserted rows in Excel 2000.

This spreadsheet is owned by one of our clients, so I can't add new
worksheets or columns to the existing workbook - I can just add cell
comments (unless you have a better suggestion).

Can anyone help?

Thanks
Steve