Reply
 
Thread Tools Display Modes
  #1   Report Post  
mary
 
Posts: n/a
Default incrementing numbers in cells in a column and copying a cell's val

I have a table in a form that a user will fill out on their PC. In the first
row of one of the columns, the user will enter a "sample number". If the
user enters a number as the value, I'd like the rest of the cells in that
column to fill in with an incremented value (30 rows in all). For example,
if the user enters "1", the next cell in that column should say "2", then
"3", etc. The same would happen if the user typed in "444". The next cell
in that column should default to "445", then "446". I want the values
defaulted throughout the 30 rows of data in that column, but I want the user
to be able to change any necessay cell's value. Also, the value for the
"sample number" column may not always be a number, in which case I don't want
the 30 cells in that column defaulted to anything. Lastly, there are other
columns in that first row in which I'd like to copy the initial value the
user enters into the rest of the cells of that particular column, again with
the user being able to change any value. One of the columns contains
checkbox fields. Can anyone help me with these issues! Thank you!
--
mary
  #2   Report Post  
Greg Maxey
 
Posts: n/a
Default

Mary,

I think you will need to run an exit macro in the Row 1 cell that you use to
enter the sample number. Bookmark the textfield in row 1 as SeqNum1.
Bookmark the 29 remaining cells in the column SeqNum2, SeqNum3, etc. The
macro is as follows:

Sub FillCellsDown()
Dim oDoc As Document
Dim i As Integer
Set oDoc = ActiveDocument

If IsNumeric(oDoc.FormFields("SeqNum1").Result) Then
For i = 2 To 30 Step 1
oDoc.FormFields("SeqNum" & i).Result = oDoc.FormFields("SeqNum" & i -
1).Result + 1
Next
Else
For i = 2 To 30 Step 1
oDoc.FormFields("SeqNum" & i).Result = ""
Next

End If

End Sub

This should answer your first question and with it you should be able figure
out the solutions to the rest of the issues.




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

mary wrote:
I have a table in a form that a user will fill out on their PC. In
the first row of one of the columns, the user will enter a "sample
number". If the user enters a number as the value, I'd like the rest
of the cells in that column to fill in with an incremented value (30
rows in all). For example, if the user enters "1", the next cell in
that column should say "2", then "3", etc. The same would happen if
the user typed in "444". The next cell in that column should default
to "445", then "446". I want the values defaulted throughout the 30
rows of data in that column, but I want the user to be able to change
any necessay cell's value. Also, the value for the "sample number"
column may not always be a number, in which case I don't want the 30
cells in that column defaulted to anything. Lastly, there are other
columns in that first row in which I'd like to copy the initial value
the user enters into the rest of the cells of that particular column,
again with the user being able to change any value. One of the
columns contains checkbox fields. Can anyone help me with these
issues! Thank you!



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
table column width problems Dena Tables 2 March 8th 05 03:51 AM
Count below not including blank cells Bradley C. Hammerstrom Tables 1 December 14th 04 10:23 AM


All times are GMT +1. The time now is 07:32 PM.

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"