selectionner le fichier excel pour BD

camadian

XLDnaute Junior
bonjour le forum

Existe il un moyen pour que dans ma macro je puisse choisir et sélectionner un fichier excel qui me servira de référence pour pour alimenter ma listview car mon fichier ne porte pas toujours le meme nom mais sa structure est toujours identique

En vous remerciant
Camadian

Private Sub UserForm_Initialize()
Dim m As Byte, i As Long, x As Long, k As Byte
Dim Wb As Object, chemin$
Dim lig As Long
ListBox1.Clear
chemin = ThisWorkbook.Path & "\1111-1111.xls"
 

Pièces jointes

  • bef.zip
    166.2 KB · Affichages: 54
  • bef.zip
    166.2 KB · Affichages: 59
  • bef.zip
    166.2 KB · Affichages: 61

Efgé

XLDnaute Barbatruc
Re : selectionner le fichier excel pour BD

Re
Une dernière tentative:
Remplacer les deux boutons par:
VB:
Private Sub CommandButton2_Click()
Dim Fact As String, Lg As Long
Fact = TextBoxQuantite.Text
With Sheets("Feuil1")
  Lg = .Range("C:C").Find(Fact, LookIn:=xlValues).Row
  .Cells(Lg, 1).EntireRow.Delete
End With
With ListBox1
    .ColumnCount = 7
    .ColumnHeads = True
    .RowSource = Range("A2:G" & Range("A65536").End(xlUp).Row).Address
End With
End Sub
Et
VB:
Private Sub CommandButtonAjout_Click()
With Range("A65536").End(xlUp)(2)
    .Offset(0, 0).Value = UserForm2.TextBoxN°plan.Value
    .Offset(0, 1).Value = UserForm2.TextBoxQuantite.Value
    .Offset(0, 2).Value = UserForm2.TextBoxIndice.Value
    .Offset(0, 3).Value = UserForm2.TextBoxDesignation.Value
    .Offset(0, 4).Value = UserForm2.TextBoxMatiere.Value
    .Offset(0, 5).Value = UserForm2.TextBoxProtection.Value
    .Offset(0, 6).Value = UserForm2.TextBoxObservation.Value
    With Columns("B:B")
        .Columns.AutoFit
        .Rows.AutoFit
        .HorizontalAlignment = xlRight
        .VerticalAlignment = xlTop
    End With
End With
With ListBox1
    .ColumnCount = 7
    .ColumnHeads = True
    .RowSource = Range("A2:G" & Range("A65536").End(xlUp).Row).Address
End With
End Sub
Après je ne sais plus...
Cordialement
 

camadian

XLDnaute Junior
Re : selectionner le fichier excel pour BD

C'est super ca marche au poil
mais maintenant mon responsable me dit "ca serait bien si on pouvait mettre tout ca dans un document word avec du blabla devant et derrière"
j'espere que je vais pouvoir transposer tout ca sous word !!!

Un grand merci a toi pour ton aide
Cordialement
Camadian
 

Discussions similaires

Statistiques des forums

Discussions
312 780
Messages
2 092 048
Membres
105 169
dernier inscrit
izarabooki