Tu ne peux pas appeler une macro située dans un module de feuille depuis un userform
Call Feuil1.MaMacro 'Feuil1 => CodeName
Mais si, on peut l'appeler de n'importe où, mais il faut préciser la feuille :
Code :
Call Feuil1.MaMacro 'Feuil1 => CodeName
A+
la procédure ne doit pas être déclarée en "Private", enlève ce mot si c'est le cas...alors pourquoi sa ne marche pas ???
alors pourquoi sa ne marche pas ???
Sub date_heurs()
' ---------------------------
' - insertion date et heurs -
' - colonne c -
' ---------------------------
Dim x As Long, i As Long, t, TT() As Double 'job75 : déclaré Double (pas As Date)
Application.ScreenUpdating = False
With Sheets("Données_brute")
.Columns(3).Insert
x = .Columns(1).SpecialCells(xlCellTypeConstants, 1).Count 'job75 : mettre des dates en colonne A...
t = .Range("A2:B" & x + 1) 'job75 : enlevé Set, et manquait + 1 (on commence en ligne 2)
ReDim TT(1 To x) 'job7 : manquait 1 To...
For i = 1 To x
TT(i) = t(i, 1) + t(i, 2) 'job75 : CDate était inutile...
Next
.Range("C1:C" & x) = Application.Transpose(TT) 'job75 : en ligne 1, sûr ?
.Columns(3).NumberFormat = "dd/mm/yyyy hh:mm"
.Columns(3).AutoFit
End With
'Call Module1.Transfaire 'mis en commentaire pour tester
End Sub
Sub date_heurs()
' ---------------------------
' - insertion date et heurs -
' - colonne c -
' ---------------------------
Application.ScreenUpdating = False
With Sheets("Données_brute")
.Columns(3).Insert
.Columns(1).Copy .Columns(3)
.Columns(2).Copy
.Columns(3).PasteSpecial Paste:=xlPasteValues, Operation:=xlAdd 'addition
.Columns(3).NumberFormat = "dd/mm/yyyy hh:mm"
.Columns(3).AutoFit
End With
'Call Module1.Transfaire 'mis en commentaire pour tester
End Sub
Sub date_heurs()
' ---------------------------
' - insertion date et heurs -
' - colonne c -
' ---------------------------
Application.ScreenUpdating = False
With Sheets("Données_brute")
.Columns(3).Insert
.Columns(1).Copy .Columns(3)
.Columns(2).Copy
.Columns(3).PasteSpecial Paste:=xlPasteValues, Operation:=xlAdd 'addition
.Columns(3).NumberFormat = "dd/mm/yyyy hh:mm"
.Columns("D:E").NumberFormat = "General" 'sinon elles ont le format Date
.Columns.AutoFit
End With
Call Transfaire
End Sub
Sub Transfaire() 'Je préfèrerais Transfert...
Dim sh As Worksheet, deb&, i&, j%, P As Boolean
'Application.Calculation = -4135 'paraît tout à fait inutile...
Set sh = Sheets("données_brute")
With Sheets("données")
deb = IIf(.[A1] = "", 1, .[A65536].End(xlUp).Row + 1)
sh.UsedRange.Copy .Cells(deb, 1)
.Columns.AutoFit 'dimensionnement des colonnes
.Cells.Sort .[C1], xlAscending, Header:=xlGuess
'suppression des lignes doublons
For i = .[A65536].End(xlUp).Row To 2 Step -1
P = True
For j = 1 To 26
If .Cells(i, j) <> .Cells(i - 1, j) Then P = False: Exit For
Next
If P Then .Rows(i).Delete
Next
End With
'Application.Calculation = -4105
Sheets("Données_brute").Cells.Delete
End Sub
For i = 1 To .[A1].End(xlUp).Row
For i = 1 To .[A1].End(xlUp).Row
For i = 1 To 1
Private Sub CommandButton1_Click()
Dim strPath$, strFile$, i As Long
strPath = UserForm2.Données_txt.Value
With ThisWorkbook.Sheets(1)
'For i = 1 To 1 '.[A1].End(xlUp).Row ne sert plus a rien
'strFile = .Cells(i, 1).Text ne sert plus a rien et devient=>
strFile = UserForm2.TextBox4.Value
Application.ScreenUpdating = False
With ActiveWorkbook.Worksheets("Données_brute")
With .QueryTables.Add(Connection:="TEXT;" & strPath & strFile, _
Destination:=.[A65536].End(xlUp).Offset)
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileSemicolonDelimiter = True
.TextFileColumnDataTypes = Array(1)
.Refresh BackgroundQuery:=False
End With
.[a1].CurrentRegion.Columns.AutoFit
End With
' Next i ne sert plus a rien
End With
Application.ScreenUpdating = False
Call Feuil7.date_heurs
End
End Sub