Discussion Locked

Macro for Repetitive Fields

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi guys,
I work at the Tasmanian Department of Police and Public Safety in Australia and I need to figure something out.
I am writing (or adding to) a Word Macro that needs to read in information into six fields (columns) for as many rows as thereare forensic items to be logged.
Can I use a for loop (For I = 1 to 20) and include the I on form fields (i.e. TextFieldNameI) to get fields called TextFieldName1 through TextFieldName20? or do I use TextFieldName(20) or [20] or .20???
Any input appreciated.

4 replies

by dklippert

Try using a For loop and then concatenate the textfieldname.

Sub Looper
For X = 1 to 20
NewFieldName = "TextFieldName" & X
MsgBox NewFieldName
Next X
End Sub

by elomis

Thanks for that, as is often the case I switched it over to someone in development to round off in a minute before it went through but what they did is more or less exactly that.. I knew what had to be done, just not exactly how to do it *copy and paste into notes file* It's there for next time.

This discussion is closed to new replies.