Hello sorry for my english I'm French
. I would like to fill an array automatically with strings defined in advance.
We start from the basic table with 1 column and 2 rows and with a macro we generate two other columns filled with the names "Zz (number of hardware) Name" in the column "Name and" Zz (number of hardware) Status "in the "State.
What I manage to do is the part framed in green. But it will be necessary that I manage to copy the number of the hardwares (1,2,3, etc ...) between "Zz" and "Name" and "Zz" and "State" so that it makes "Zz2Name" and " Zz2State "if I am at hardware N ° 2.
What I can't do is in the part framed in red. I would like that if the user wishes to enter X hardwares so that he himself creates X lines that with the macro the X lines created are filled with the names according to the number of the hardware.
I don't know if I was clear enough in my explanations.
But here is my code which makes it possible to make the framed green part, it would just be necessary to add for this macro the copy of the material number between "Zz" and "Name" and "Zz" and "State" to avoid that I write it manually at each line.
Code :
Code:
Sub test_Tableau()
Dim tab_1 As Table
Set tab_1 = ActiveDocument.Tables(1)
If ActiveDocument.Tables.Count >= 1 Then
tab_1.Columns.Width = InchesToPoints(1.66)
Selection.InsertColumnsRight
Selection.InsertColumnsRight
If tab_1.Rows.Count = 2 Then
With tab_1.Cell(Row:=1, Column:=2).Range
.InsertAfter Text:="Nom"
End With
With tab_1.Cell(Row:=1, Column:=3).Range
.InsertAfter Text:="Etat"
With tab_1.Cell(Row:=2, Column:=2).Range
.InsertAfter Text:="Zz1Etat"
End With
With tab_1.Cell(Row:=2, Column:=3).Range
.InsertAfter Text:="Zz1Nom"
End With
End With
End If
End If
End Sub
Any help will be welcome
Thank you in advance !
PS :
I will attach an explanatory picture of what I would like to do.