formatting database output to excel by deleting duplicates

  • Thread starter Thread starter steve
  • Start date Start date
S

steve

I have heirarchical output from a database and want to
delete content for all duplicate entries, leaving just
the heirarchy exposed in excel.

How would I make a macro to do these deletions for the
whole worksheet?
 
steve said:
I have heirarchical output from a database and want to
delete content for all duplicate entries, leaving just
the heirarchy exposed in excel.

Heirarchical data cannot be easily shown in a worksheet's cells. I'd
normally use a dedicated control such as a treeview or MSHFlexGrid
ActiveX control., but you could potentially use Excel's 'Group and
Ouline' feature I suppose.

Out of interest, what how do you retrieve your data e.g. are you
returning a hierarchical ADO recordset using the MSDataShape provider
and the SHAPE syntax? If so, and you have access to VB6, I'd recommend
taking a look at binding your recordset to a DataReport and finding a
way of exposing this to your Excel users.

Anyhow, my advise would be to eliminate duplicate data via the data
engine i.e. re-write your query to return only unique data. This
realty is the point of using SQL : it deals with data as sets whereas
to do the same in Excel you'd have to use procedural code with a
cursor and would be much slower.

[I wonder if, rather than having heirarchical data, you instead have a
flat data structure being the result set of a SQL JOIN on a
one-to-many relationship. Who knows if you don't supply any schema
information, sample data, code, SQL, DDL...?]

--
 

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