1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| Sub tab1()
Dim entete, new_nom$, themes, lignes
entete = Array("toto", "titi", "riri", "fifi", "loulou", "truc", "bidule", "machin", "chose")
new_nom = "pannel1"
lignes = 6
themes = "truc bidule" & Date & "/" & "machin"
create_tableau entete, new_nom, themes, lignes
End Sub
Function create_tableau(entete, new_nom As String, themes As String, lignes As Long)
With ActiveSheet
'************************************************************************************
'ici je voudrais le supprimer si il existe ainsi que tout mise en couleur ou format sur la plage occupée par le tableau
Set temp = Range(new_nom & "[#All]")
If Not temp Is Nothing Then
'.ListObjects(new_nom).Unlist
Union(temp, temp.Offset(-2)).EntireRow.Delete
End If
'************************************************************************************
.Cells(Rows.Count, 1).End(xlUp).Offset(1) = themes
.ListObjects.Add(xlSrcRange, .Cells(Rows.Count, 1).End(xlUp).Offset(2).Resize(lignes, UBound(entete) + 1), , xlNo).Name = new_nom
.ListObjects(new_nom).TableStyle = "TableStyleMedium11"
With Range(new_nom & "[#Headers]")
.Value = entete
.Interior.Color = RGB(0, 100, 0)
.Font.Color = vbWhite
End With
'model d'acces a une colonne :
'MsgBox Range(new_nom & "[titi]").Address
End With
End Function |
Partager