peterskrystalk
New Member
- Joined
- Jun 3, 2014
- Messages
- 3
I have an excel workbook with a list of contracts to be submitted. The information in the workbook is used to create a email (form) where the information is filled in and files are attached. Originally the code:
For Each rCol In tbl.DataBodyRange
'***************************************************
' Contracting Entity - place the value of the cell in the variable
'***************************************************
If rCol.Column = 1 Then
Entity = rCol.Text
'***************************************************
' Vendor Name - place the value of the cell in this column &row in the variable
'***************************************************
ElseIf rCol.Column = 2 Then
Vndr = rCol.Text
and so on...would populate a variable base on the number of the column. Since then I have had to rearrange and add more columns - and edit my code. How can this be coded so I am not dependent on the location of the column but just the name.. So that if any future addition or rearrangement happens, I don't have to modify all my code, I can just add the reference to the new column.
thanks, peterskrystalk
For Each rCol In tbl.DataBodyRange
'***************************************************
' Contracting Entity - place the value of the cell in the variable
'***************************************************
If rCol.Column = 1 Then
Entity = rCol.Text
'***************************************************
' Vendor Name - place the value of the cell in this column &row in the variable
'***************************************************
ElseIf rCol.Column = 2 Then
Vndr = rCol.Text
and so on...would populate a variable base on the number of the column. Since then I have had to rearrange and add more columns - and edit my code. How can this be coded so I am not dependent on the location of the column but just the name.. So that if any future addition or rearrangement happens, I don't have to modify all my code, I can just add the reference to the new column.
thanks, peterskrystalk