Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
table column width problems | Tables | |||
Count below not including blank cells | Tables |