Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.tables
kaz
 
Posts: n/a
Default Auto number a column in table using SEQ

Hi there

I have created a table and have used the SEQ formula to have a
sequential number in the first column. When I copy the row the SEQ
works fine - i.e. it auto-increments the number. But if I tab through
the row (the last row of the table) and it creates a new row the SEQ is
obviously not there. I can understand the logic of that but is there
some other way of having a sequential number automatically
incrementating that will work if I copy the row as well as tabbing
through the last row on the table.

Cheers
Kaz

  #2   Report Post  
Posted to microsoft.public.word.tables
kaz
 
Posts: n/a
Default Auto number a column in table using SEQ

Actuslly, can I add another bit to this question? I see that I can use
standard list numbering to achieve the sequential number bit. But I am
also using a Count function to count the number of rows. When I use
standard list numbering my Count function doesn't work anymore.

  #3   Report Post  
Posted to microsoft.public.word.tables
Doug Robbins - Word MVP
 
Posts: n/a
Default Auto number a column in table using SEQ

Where and for what are you using the count function. The number in the last
row will equal the count will it not?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"kaz" wrote in message
ups.com...
Actuslly, can I add another bit to this question? I see that I can use
standard list numbering to achieve the sequential number bit. But I am
also using a Count function to count the number of rows. When I use
standard list numbering my Count function doesn't work anymore.



  #4   Report Post  
Posted to microsoft.public.word.tables
kaz
 
Posts: n/a
Default Auto number a column in table using SEQ

I have a field, outside of the table, that needs to display the count
of the number of items in the table (excluding the header row).

  #5   Report Post  
Posted to microsoft.public.word.tables
Suzanne S. Barnhill
 
Posts: n/a
Default Auto number a column in table using SEQ

You might want to have a look at
http://gregmaxey.mvps.org/Table_Cell_Data.htm. If this macro doesn't do what
you need, perhaps Greg could enhance it so that it would. I would think that
any macro that could put information in the status bar could also write it
to a document property or variable that could be picked up in the doc with a
DocProperty or DocVariable field.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

"kaz" wrote in message
oups.com...
I have a field, outside of the table, that needs to display the count
of the number of items in the table (excluding the header row).




  #6   Report Post  
Posted to microsoft.public.word.tables
kaz
 
Posts: n/a
Default Auto number a column in table using SEQ

Wow, that looks pretty complex. I thought I could do something as
simple as using Count pointing to the column in the table (where I have
bookmarked the table). I do have a good book that shows me how to get
the information from the status bar so will work on that. If there is a
simpler solution can someone please let me know.

  #7   Report Post  
Posted to microsoft.public.word.tables
Greg Maxey
 
Posts: n/a
Default Auto number a column in table using SEQ

Alot will depend on how you define an "item." Do you mean a cell containing
any text?

Something like this may do. You can nest a docvarialbe field in a macro
button field to execute:

Sub ScratchMacro()
Dim oTbl As Word.Table
Dim i&
Dim rowCnt&
Dim colCnt&
Dim myVar As Variable
Set oTbl = ActiveDocument.Tables(1)
For rowCnt = 2 To oTbl.Rows.Count
For colCnt = 1 To oTbl.Columns.Count
If Len(oTbl.Cell(rowCnt, colCnt).Range.Text) 2 Then
i = i + 1
End If
Next colCnt
Next rowCnt
ActiveDocument.Variables("myVar").Value = i
ActiveDocument.Fields.Update
End Sub

The field will look something like this:

{ Macrobutton Scratchmacro {DocVariable myVar}}

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Suzanne S. Barnhill wrote:
You might want to have a look at
http://gregmaxey.mvps.org/Table_Cell_Data.htm. If this macro doesn't
do what you need, perhaps Greg could enhance it so that it would. I
would think that any macro that could put information in the status
bar could also write it to a document property or variable that could
be picked up in the doc with a DocProperty or DocVariable field.


"kaz" wrote in message
oups.com...
I have a field, outside of the table, that needs to display the count
of the number of items in the table (excluding the header row).



  #8   Report Post  
Posted to microsoft.public.word.tables
kaz
 
Posts: n/a
Default Auto number a column in table using SEQ

Yes, I guess a cell containing any text. What I have is a table where
the first column is a sequential number, automatically generated for
each new row. I am currently creating that number just using standard
list numbering. I did have my field (outside of the table) simply doing
a COUNT on that first column but that doesn't work. I am guessing that
is because Word doesn't recognise the content of the field as being
numeric?!? So if I use the code described by Greg, how do I ensure that
is pointed to that specific table (as my document has a few other
tables in it). When I was trying to do this using COUNT I had
bookmarked the table in question and used that bookmark name in the
COUNT function. Do I just change the "Set oTbl" statement to point to
the bookmark?

  #9   Report Post  
Posted to microsoft.public.word.tables
Greg Maxey
 
Posts: n/a
Default Auto number a column in table using SEQ

Kaz,

Provided that your bookmark spans only the table of interest, you could use
this line (all on one line):

Set oTbl = ActiveDocument.Bookmarks("mytable").Range.Tables(1 )

where "mytable" stands in for the name of your bookmark.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


kaz wrote:
Yes, I guess a cell containing any text. What I have is a table where
the first column is a sequential number, automatically generated for
each new row. I am currently creating that number just using standard
list numbering. I did have my field (outside of the table) simply
doing a COUNT on that first column but that doesn't work. I am
guessing that is because Word doesn't recognise the content of the
field as being numeric?!? So if I use the code described by Greg, how
do I ensure that is pointed to that specific table (as my document
has a few other tables in it). When I was trying to do this using
COUNT I had bookmarked the table in question and used that bookmark
name in the COUNT function. Do I just change the "Set oTbl" statement
to point to the bookmark?



  #10   Report Post  
Posted to microsoft.public.word.tables
kaz
 
Posts: n/a
Default Auto number a column in table using SEQ

Hi Greg

I'm getting there (slowly). So, my macro is now giving me the result I
want and I can get the result displayed in the required place in the
document. But I have achieved this by manually running the macro then
updating the field using F9. I am guessing that the command "{
Macrobutton Scratchmacro {DocVariable myVar}} " that you supplied is
supposed to run the macro as well as displaying the variable but I
can't get that to work. I'm (obviously) new to all of this so it is
probably the way I am creating / recording the macro or the actual
syntax. Can you please just help me one more time?

Cheers
Kaz



  #11   Report Post  
Posted to microsoft.public.word.tables
Greg Maxey
 
Posts: n/a
Default Auto number a column in table using SEQ

Kaz

{macrobutton scratchmacro {docvariable myvar}}

Is a DocVariable field, nested in a macrobutton field.

The { } pairs are entered with CTRL+F9. When the field results are
displayed are you will see is the count or the number. If you doubleclick
that number, you will fire the macro to recalculate. See:
http://gregmaxey.mvps.org/Word_Fields.htm for more on Word fields.


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


kaz wrote:
Hi Greg

I'm getting there (slowly). So, my macro is now giving me the result I
want and I can get the result displayed in the required place in the
document. But I have achieved this by manually running the macro then
updating the field using F9. I am guessing that the command "{
Macrobutton Scratchmacro {DocVariable myVar}} " that you supplied is
supposed to run the macro as well as displaying the variable but I
can't get that to work. I'm (obviously) new to all of this so it is
probably the way I am creating / recording the macro or the actual
syntax. Can you please just help me one more time?

Cheers
Kaz



  #12   Report Post  
Posted to microsoft.public.word.tables
kaz
 
Posts: n/a
Default Auto number a column in table using SEQ

Okey dokey. Got that bit working. But, is there some other way of
executing the macro? I will be providing the document to users to fill
in. I am not sure about getting them to double-click to run the macro.
Other templates we have created require the user to Select All and then
Press F9. Is there an alternative method for running the macro?

  #13   Report Post  
Posted to microsoft.public.word.tables
Greg Maxey
 
Posts: n/a
Default Auto number a column in table using SEQ

Kaz,

You could add a prompt:
{ Macrobutton Scratchmacro "Double click to count items: { Docvariable
myVar }" }

AFAIK other than that, you would have to assign the macro to a keyboard
shortcut, menu, or toolbar icon.

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

"Greg Maxey" wrote in message
...
Alot will depend on how you define an "item." Do you mean a cell
containing any text?

Something like this may do. You can nest a docvarialbe field in a macro
button field to execute:

Sub ScratchMacro()
Dim oTbl As Word.Table
Dim i&
Dim rowCnt&
Dim colCnt&
Dim myVar As Variable
Set oTbl = ActiveDocument.Tables(1)
For rowCnt = 2 To oTbl.Rows.Count
For colCnt = 1 To oTbl.Columns.Count
If Len(oTbl.Cell(rowCnt, colCnt).Range.Text) 2 Then
i = i + 1
End If
Next colCnt
Next rowCnt
ActiveDocument.Variables("myVar").Value = i
ActiveDocument.Fields.Update
End Sub

The field will look something like this:

{ Macrobutton Scratchmacro {DocVariable myVar}}

--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.


Suzanne S. Barnhill wrote:
You might want to have a look at
http://gregmaxey.mvps.org/Table_Cell_Data.htm. If this macro doesn't
do what you need, perhaps Greg could enhance it so that it would. I
would think that any macro that could put information in the status
bar could also write it to a document property or variable that could
be picked up in the doc with a DocProperty or DocVariable field.


"kaz" wrote in message
oups.com...
I have a field, outside of the table, that needs to display the count
of the number of items in the table (excluding the header row).





  #14   Report Post  
Posted to microsoft.public.word.tables
kaz
 
Posts: n/a
Default Auto number a column in table using SEQ

Thanks for all your help. Fantastic help to me.

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Document Styles should be assignable to fonts in Table AutoFormat Natasha A. Tables 5 November 11th 05 05:49 PM
How do i have differ column widths for each row in a word table? zulto Tables 1 November 5th 05 03:36 PM
Format a number column in a table DianePDavies Microsoft Word Help 1 October 6th 05 09:39 AM
Table headers/footers and layout Keith Page Layout 1 April 8th 05 07:37 PM
Dragging table column resets Sedonakids Tables 0 January 12th 05 01:11 AM


All times are GMT +1. The time now is 10:17 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"