Ajouter un commentaire

xdidix
problem Range "Excel-VB6"

bonjour sa-fait une semaine que je chercher a résoudre un problème dans mon code mais sans résulta
mon problème c'est quant je clic sur le bouton pour remplier une LISTBOX l'erreur suivante surgi ( Method 'Range' of object'_Global' failed)
je crois c 'est a cause de la fermeture d'un classeur "Excel" et l'ouverture d'un autre bref le voila mon code :

Private Sub Form_Load()

Dim appExcel As Excel.Application
Dim wbExcel As Excel.Workbook
Dim wsExcel As Excel.Worksheet

Set appExcel = CreateObject("Excel.Application")
Set wbExcel1 = appExcel.Workbooks.Open(App.Path & "\branchETclasse.xlsx")
Set wsExcel1 = wbExcel1.Worksheets(1)
appExcel.Visible = True

Call remplirecombo

Workbooks.Close

End Sub

Private Sub remplirecombo()

Dim i As Integer

Dim j As Integer

Dim nbBranch As Integer

Dim nbClasse As Integer

Dim Bra As Range

Dim Cla As Range

Set Bra = Range("A1")

Set Cla = Range("B1")

nbBranch = Bra.End(xlDown).Row - 1
nbClasse = Cla.End(xlDown).Row - 1

For i = 0 To nbBranch

For j = 0 To nbBranch
Combo1.AddItem Bra.Offset(i, 0)
Exit For
Exit For

Next j
Next i

For i = 0 To nbClasse

For j = 1 To nbClasse

Combo2.AddItem Bra.Offset(i, 1)
Exit For
Exit For

Next j
Next i

End Sub

Private Sub Command5_Click()

If Combo1.ListIndex <> 0 Or Combo2.ListIndex <> 0 Then
MsgBox ("la liste est vide")
Else
Call listboxRemp
End If

End Sub

Private Sub listboxRemp()

Dim appExcel As Excel.Application
Dim wbExcel As Excel.Workbook
Dim wsExcel As Excel.Worksheet

Set appExcel = CreateObject("Excel.Application")
Set wbExcel1 = appExcel.Workbooks.Open(App.Path & "\test.xlsx")
Set wsExcel1 = wbExcel1.Worksheets(1)
appExcel.Visible = True

Dim nbgroupA As Integer

Dim groupA As Range

Set groupA = Range("A1") ' erreur :( :s

nbgroupA = groupA.End(xlDown).Row - 1

For i = 0 To nbgroupA
For j = 1 To nbgroupA

List1.AddItem groupA.Offset(i, 1)

Exit For
Exit For

Next j
Next i

End Sub

Filtered HTML

Plain text

CAPTCHA
Cette question permet de vérifier que vous n'êtes pas un robot spammeur :-)
 DDD   V     V  PPPP   K  K  EEEE 
D D V V P P K K E
D D V V PPPP KK EEE
D D V V P K K E
DDD V P K K EEEE