Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
540 connectés 

  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  argument non facultatif

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

argument non facultatif

n°2001347
gregouarf
Posté le 13-06-2010 à 21:37:50  profilanswer
 

Bonjour,
Je rencontre actuellement un problème lors de l'appel d'une fonction dans une autre.
En effet, excel me renvoie "argument non facultatif".
Pourtant je pense renseigner tous les arguments demandés.
 
Voici le code de la fonction qui appelle l'autre :  
 
 
 
 
Sub info(descr As String)
 
Dim e As Integer
Dim d As String
Dim k As Variant
 
Application.ScreenUpdating = False
d = descr
Call CreateInfoSheet("info", d)     'c'est ici que la fonction est appelée!
 
 
e = EmptyLine("info", 1)
 
If e = 3 Then
 
Worksheets("Main" ).Select
MsgBox "Component Deleted"
 
Else
 
For i = 3 To e - 1
Worksheets("Main" ).Select
Select Case MsgBox("There is " & e - 3 & " Locations" & Chr(10) & _
        " " & Chr(10) & _
        "Location " & i - 2 & " : " & Chr(10) & _
        " " & Chr(10) & _
        "Room : " & Sheets("info" ).Range("C" & i) & Chr(10) & _
        "Cupboard : " & Sheets("info" ).Range("D" & i) & Chr(10) & _
        "Box : " & Sheets("info" ).Range("E" & i) & Chr(10) & _
        "Location : " & Sheets("info" ).Range("F" & i) & Chr(10) & _
        "Quantity : " & Sheets("info" ).Range("G" & i) & Chr(10) & _
        " " & Chr(10) & _
        "More Info?", vbYesNo, "location founded" )
Case vbYes
MsgBox "Location " & i - 2 & " : " & Chr(10) & _
        " " & Chr(10) & _
        "Room : " & Sheets("info" ).Range("C" & i) & Chr(10) & _
        "Cupboard : " & Sheets("info" ).Range("D" & i) & Chr(10) & _
        "Box : " & Sheets("info" ).Range("E" & i) & Chr(10) & _
        "Location : " & Sheets("info" ).Range("F" & i) & Chr(10) & _
        "Quantity : " & Sheets("info" ).Range("G" & i) & Chr(10) & _
        "Price/pieces : " & Sheets("info" ).Range("H" & i) & Chr(10) & _
        "Total Price : " & Sheets("info" ).Range("I" & i) & Chr(10) & _
        "Company : " & Sheets("info" ).Range("J" & i) & Chr(10) & _
        "Link : " & Sheets("info" ).Range("K" & i)
Case vbNo
Worksheets("Main" ).Select
End Select
Next
End If
 
End Sub
 
 
 
Et voici le code de la fonction appelée :  
 
 
 
 
Sub CreateInfoSheet(name As String, descr As String)
 
Dim a As Variant
    Dim b As String
    Dim k As Integer
    Dim l As Integer
    Dim d As String
    l = 3
    k = EmptyLine("All components", 2)
    b = name
    d = descr
     
    Application.ScreenUpdating = False
    'new sheet's creation
    Application.DisplayAlerts = False
    If SheetExist(b) = True Then
    Sheets(b).Delete
    End If
    Sheets("All components" ).Select
    Range("A1" ).Select
    a = Selection.EntireRow
    Sheets("Main" ).Select
    Sheets.Add
    ActiveSheet.name = b
    Columns("A:A" ).ColumnWidth = Sheets("All components" ).Columns("A:A" ).ColumnWidth
    Columns("B:B" ).ColumnWidth = Sheets("All components" ).Columns("B:B" ).ColumnWidth
    Columns("C:C" ).ColumnWidth = Sheets("All components" ).Columns("C:C" ).ColumnWidth
    Columns("D:D" ).ColumnWidth = Sheets("All components" ).Columns("D:D" ).ColumnWidth
    Columns("E:E" ).ColumnWidth = Sheets("All components" ).Columns("E:E" ).ColumnWidth
    Columns("F:F" ).ColumnWidth = Sheets("All components" ).Columns("F:F" ).ColumnWidth
    Columns("G:G" ).ColumnWidth = Sheets("All components" ).Columns("G:G" ).ColumnWidth
    Columns("H:H" ).ColumnWidth = Sheets("All components" ).Columns("H:H" ).ColumnWidth
    Columns("I:I" ).ColumnWidth = Sheets("All components" ).Columns("I:I" ).ColumnWidth
    Columns("J:J" ).ColumnWidth = Sheets("All components" ).Columns("J:J" ).ColumnWidth
    Columns("K:K" ).ColumnWidth = Sheets("All components" ).Columns("K:K" ).ColumnWidth
    Columns("L:L" ).ColumnWidth = Sheets("All components" ).Columns("L:L" ).ColumnWidth
    Columns("M:M" ).ColumnWidth = Sheets("All components" ).Columns("M:M" ).ColumnWidth
    Columns("N:N" ).ColumnWidth = Sheets("All components" ).Columns("N:N" ).ColumnWidth
    'Sheet's Title
    Range("A1:C1" ).Select
    Selection.Merge
    Sheets(b).Cells(1, 1).Value = b & ", " & Sheets("Main" ).Cells(7, 1).Value & ", " & Year(Date) & "/" & Month(Date) & "/" & Day(Date) & ", " & Time
    Selection.EntireRow.Select
    Selection.Font.Bold = True
    'column's heads
    Range("A2" ).Select
    Selection.EntireRow = a
    Selection.EntireRow.Select
    Selection.Font.Bold = True
     
    'writting in the new sheet
     
    For i = 2 To k
    If Sheets("All components" ).Cells(i, 2).Value = d Then
    Sheets("All components" ).Select
    Range("A" & i).Select
    a = Selection.EntireRow
    Sheets(b).Select
    Range("A" & l).Select
    Selection.EntireRow = a
    l = l + 1
    End If
    Next
     
End Sub
 
J'espère que quelqu'un pourra m'aider.
Merci.

mood
Publicité
Posté le 13-06-2010 à 21:37:50  profilanswer
 

n°2001424
SuppotDeSa​Tante
Aka dje69r
Posté le 14-06-2010 à 11:33:15  profilanswer
 

Hello
 
Perso j'aime pas trop l'instruction Call

Code :
  1. CreateInfoSheet "info", d

Suffi largement
 
As tu vérifié que tes variables contiennent toutes qquchose ?
Ensuite tu n'appelles pas une fonction mais une procedure, CreateInfoSheet.
Pourquoi repasser par une variable d ??


---------------
Soyez malin, louez entre voisins !

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  VB/VBA/VBS

  argument non facultatif

 

Sujets relatifs
Macro Excel: Pivottables: Argument ou Appel de procédure incorrectVBS -> bat avec argument
[Python3] tkinter: Scale Comment faire passer un argumentArgument -- dans un shell UNIX
[Resolu] Passage d'argument a un threadPasser autre chose qu'un text en argument à POST ?
[Boost::random] Template comme argument d'une fonction...COM C++/VB6 tableau de string en argument
Fonction avec argument facultatif[VBA-EXCEL 2003] argument non facultatif pour textbox
Plus de sujets relatifs à : argument non facultatif


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR