Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting a group of tables based on table heading

Status
Not open for further replies.

bja2003

Technical User
Nov 11, 2003
2
AU
Hi.

In brief, I am trying to sort a group of tables (1,200 odd) into an order determined by the contents of row(1), cell(1) and would appreciate any help given.

Below is the detailed situation. Apologies in advance for its length.

I am trying to import three database tables (each is a list of table attributes). I then need to sort the tables based on the table name, fill in any missing duplications (as explained below), reformat the layout and automate the lot based on dialog box input.

I started six weeks ago part-time with very basic VBA skills (macro record button knowledge only). I've been full-time on this for the last two weeks and I have since solved most of the issues EXCEPT the sorting aspect. My VBA is heaps better now but I cannot get beyond the sorting of the first two tables and as time is now becoming critical, I'm hoping someone can offer some assistance.

TIA if you can.

Here is the current situation in regards to the tables:

I have imported three database tables into Word 2000.
For example:

GroupA - 4 columns: tbl_name, col_name, col_num, desc
GroupB - 3 columns: tbl_name, col_name, desc
GroupC - 3 columns: tbl_name, col_name, desc
Each table consists of many rows.

Using VBA I have split the tables based on the content of column(1). This has created a number of separate tables as follows:

GroupA-Table1
GroupA-Table2
GroupA-Table3
GroupA-Table4

GroupB-Table1
GroupB-Table2
GroupB-Table5
GroupB-Table6

GroupC-Table1
GroupC-Table2
GroupC-Table5
GroupC-Table7

Now I need to group them by their table names [column(1)].

The end product then needs to have a placeholder table inserted where a table is missing.

The end result needs to be as follows:

GroupA-Table1
GroupB-Table1
GroupC-Table1

GroupA-Table2
GroupB-Table2
GroupC-Table2

GroupA-Table3
GroupB-Table3 - placeholder table needed
GroupC-Table3 - placeholder table needed

GroupA-Table4
GroupB-Table4 - placeholder table needed
GroupC-Table4 - placeholder table needed

GroupA-Table5 - placeholder table needed
GroupB-Table5
GroupC-Table5

GroupA-Table6 - placeholder table needed
GroupB-Table6
GroupC-Table6 - placeholder table needed

GroupA-Table7 - placeholder table needed
GroupB-Table7 - placeholder table needed
GroupC-Table7

Sorry for the long-winded explanation which I hope explains the situation clearly.

Again, TIA for any help offered.

Regards,

Bruce
 
Hi bja2003,

Before we begin, what Application are you using? You say I have imported three database tables into Word 2000. Does that mean you are trying to do all this data manipulation in Word? Do you not have Access or Excel? Or have I misunderstood?

Enjoy,
Tony
 
Hi Tony,

Thanks for the reply and sorry for not making my last email clear enough.

I've set up a number of 'views' in an Oracle database using SQL.

In Word 2000, I've created a macro that interogates the database and imports the required data (views) directly into Word.

This is deliberate because the end document needs to be in Word and the information obtained will be appended to a longer Word document.

Once all the parts are worked out, the end user (not me) will be able to click on a toolbar button which in turn will call the appropriate macros to update the document directly from the database.

Regarding Access and Excel, I do have them and I initially went down that path until I found that Word could import the data directly. So to answer your question; yes, I am trying to do all the manipulation in Word.

So far, I can get the data in, I can split the tables up, I can reformat the tables and I can insert additional columns and then have them populated with data from another file.

The only thing I haven't nutted out yet is how to do the sort as shown in my last email. I can get two of the database tables sorted but not the third.

My problem now is time which is why I've asked for help. While waiting (and hoping) I'll also be trying to work it out as it is my top priority for the moment.

I hope this clarifies things a bit.

BTW, I'm new to VBA and my programming 'skills' are limited (and very rusty) so please be kind to me :)

Regards,

Bruce

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top