PDA

View Full Version : Copy the heading numbering in the table



kamkwok6
02-07-2023, 02:36 AM
Dear All,

I am looking for a solution to copy the heading number from 1st column to the cell next to it. And after the heading number is updated on the 1st column, the prefix/number on the second column should also be updated.

Those heading number are made by a list. Here's is the sample. I don't know how it works in a MS word table.

Before:

30505
30506

After:

30504
30507

Chas Kenyon
02-07-2023, 10:01 AM
I'm not sure this is a vba question, but I don't have a vba solution. Someone else may.
What you want for those subsidiary numbers is likely a cross-reference field.

Note that headings in a table will not show upr as bookmarks in a pdf conversion, nor in the Navigation Pane.
Headings that do not show up in the Navigation Pane or in a Table of Contents (or in Cross-References / Hyperlinks)

30508

Here is a temporary link (https://www.dropbox.com/s/df1qal1stiikm4o/deleteme.docx?dl=0) to a file that uses this technique.
https://www.dropbox.com/s/df1qal1stiikm4o/deleteme.docx?dl=0

This has nothing to do with the position in the table. The cross-reference is to the heading.
Insert Cross-References (https://www.addbalance.com/usersguide/complex_documents.htm#crossreferences)

Chas Kenyon
02-07-2023, 10:07 AM
You said that the numbering comes from a list. There is only one method known to produce stable automatic numbering in Word. If you use automatic paragraph numbering or bullets read Shauna Kelly's directions on numbering and bullets. Start with How to create numbered headings or outline numbering in Word 2007 and Word 2010 (http://www.shaunakelly.com/word/numbering/numbering20072010.html). For large documents you must follow these directions or you will lose your hair!
(Mac version: https://www.brandwares.com/bestpractices/2016/06/outline-numbering-in-word-for-os-x/)

This may seem a bit convoluted at first, but it really is not. Just follow the steps. Shauna Kelly's instructions use the built-in heading styles, but you can use any existing paragraph styles including your custom styles. There are, however advantages to using the built-in heading styles when you create a Table of Contents. Here are some more advantages: Why Use Word's Built-In Heading Styles? by Shauna Kelly (http://www.addbalance.com/usersguide/10HeadingStyles.htm) Note, you can modify these built-in styles to look exactly the way you want.

If you want, I can provide links to videos demonstrating setting up numbering linked to styles.

The basic idea is that the numbering is set using the Define MultiLevel List dialog with each numbering level being attached to an existing paragraph style. Once you have this set up, you should not use the buttons for numbering in the Ribbon but rather apply the appropriate style for that level.

You can save a document with this as a template for future documents if you want so you will not need to do this every time.

kamkwok6
02-07-2023, 07:03 PM
Thanks a lot !!! It does really help in some way. However, could it be a more advanced solution with VBA? Let’s say, the VBA will automatic get the “paragraph number” of a “numbered item” from the left column of my selected cell and then insert back in my selected cell

Chas Kenyon
02-09-2023, 05:16 AM
So, write the vba to create a cross-reference field to the number of the heading in Cells(1) of the row.