guy72
XLDnaute Impliqué
Bonjour,
1) J'ai une macro qui s'appelle "WS_2300".
2) J'ai une autre macro qui s'apelle "Flèche".
Je souhaite en faire qu'une, donc j'ai mis dans "WS_2300" la ligne "Call Flèche", et là ça ne fonctionne plus.
J'ai le message suivant:
Erreur de compilation:
Variable ou procédure attendue, et non un module.
Que peut il se passer ?
C'est deux macros fonctionnent très bien séparément.
Merci de votre aide
Cordialement
Guy
------------------------------------------------------------------------------------
Sub WS_2300 ()
Dim FeWS2300 As Worksheet
Dim FeFévrier As Worksheet
Dim Source As Range
Dim Colonne As String
Set FeWS2300 = Worksheets("WS2300")
Set FeFévrier = Worksheets("Février")
With FeWS2300
'Vent
Set Source = .Range("BI5:BU5"): Colonne = "AN"
FeFévrier.Range(Colonne & 65535).End(xlUp).Offset(2, 0). _
Resize(Source.Rows.Count, Source.Columns.Count).Value = Source.Value
Call Flèche
Sheets("Février").Select
End With
End Sub
------------------------------------------------------------------------------------
Option Explicit
Const CELLULE_BASE As String = "AT11"
Sub Flèche()
Dim S As Worksheet
Dim S2 As Worksheet
Dim SH As Shape
Dim SH2 As Shape
Dim SH3 As Shape
Dim R As Range
Dim R2 As Range
Set S = Sheets("WS2300")
Set S2 = Sheets("Février")
For Each SH In S.Shapes
Set R = SH.TopLeftCell
If Not Application.Intersect(R, S.Range("BO4:BO6")) Is Nothing Then
SH.Copy
S2.Select
Set R2 = S2.Range(CELLULE_BASE)
For Each SH2 In S2.Shapes
Do Until SH2.TopLeftCell.Address <> R2.Address
Set R2 = R2.Offset(2, 0)
Loop
Next SH2
R2.Select
S2.PasteSpecial Format:="Image (PNG)", Link:=False, DisplayAsIcon:=False
Set SH3 = S2.Shapes(S2.Shapes.Count)
If SH3.Width < R2.Width Then
SH3.Left = SH3.Left + (R2.Width - SH3.Width) / 2
End If
If SH3.Height < R2.Height Then
SH3.Top = SH3.Top + (R2.Height - SH3.Height) / 2
End If
R2.Select
Exit For
End If
Next SH
End Sub
1) J'ai une macro qui s'appelle "WS_2300".
2) J'ai une autre macro qui s'apelle "Flèche".
Je souhaite en faire qu'une, donc j'ai mis dans "WS_2300" la ligne "Call Flèche", et là ça ne fonctionne plus.
J'ai le message suivant:
Erreur de compilation:
Variable ou procédure attendue, et non un module.
Que peut il se passer ?
C'est deux macros fonctionnent très bien séparément.
Merci de votre aide
Cordialement
Guy
------------------------------------------------------------------------------------
Sub WS_2300 ()
Dim FeWS2300 As Worksheet
Dim FeFévrier As Worksheet
Dim Source As Range
Dim Colonne As String
Set FeWS2300 = Worksheets("WS2300")
Set FeFévrier = Worksheets("Février")
With FeWS2300
'Vent
Set Source = .Range("BI5:BU5"): Colonne = "AN"
FeFévrier.Range(Colonne & 65535).End(xlUp).Offset(2, 0). _
Resize(Source.Rows.Count, Source.Columns.Count).Value = Source.Value
Call Flèche
Sheets("Février").Select
End With
End Sub
------------------------------------------------------------------------------------
Option Explicit
Const CELLULE_BASE As String = "AT11"
Sub Flèche()
Dim S As Worksheet
Dim S2 As Worksheet
Dim SH As Shape
Dim SH2 As Shape
Dim SH3 As Shape
Dim R As Range
Dim R2 As Range
Set S = Sheets("WS2300")
Set S2 = Sheets("Février")
For Each SH In S.Shapes
Set R = SH.TopLeftCell
If Not Application.Intersect(R, S.Range("BO4:BO6")) Is Nothing Then
SH.Copy
S2.Select
Set R2 = S2.Range(CELLULE_BASE)
For Each SH2 In S2.Shapes
Do Until SH2.TopLeftCell.Address <> R2.Address
Set R2 = R2.Offset(2, 0)
Loop
Next SH2
R2.Select
S2.PasteSpecial Format:="Image (PNG)", Link:=False, DisplayAsIcon:=False
Set SH3 = S2.Shapes(S2.Shapes.Count)
If SH3.Width < R2.Width Then
SH3.Left = SH3.Left + (R2.Width - SH3.Width) / 2
End If
If SH3.Height < R2.Height Then
SH3.Top = SH3.Top + (R2.Height - SH3.Height) / 2
End If
R2.Select
Exit For
End If
Next SH
End Sub
Dernière édition: