OVH Cloud OVH Cloud

Erreur inexplicable sur select

6 réponses
Avatar
defluc
Bonjour

Après une journée de recherche, je ne trouve pas pourquoi j'ai une
«erreur d'exécution '1004' : Erreur définie par l'application ou par
l'objet» après la deuxième instruction ci-après :

Sheets(6).Activate
ActiveSheet.Range(Cells(26, 10), Cells(117, 12)).Select

Merci d'avance

6 réponses

Avatar
Michel
Salut,

J'ai teste et pas d'erreur...

As tu un autre code avant ? des donnees specifique dans les cellules que tu
selectionnes ?

@+

Michel.


"defluc" a écrit dans le message de news:

Bonjour

Après une journée de recherche, je ne trouve pas pourquoi j'ai une «erreur
d'exécution '1004' : Erreur définie par l'application ou par l'objet»
après la deuxième instruction ci-après :

Sheets(6).Activate
ActiveSheet.Range(Cells(26, 10), Cells(117, 12)).Select

Merci d'avance


Avatar
Jean-Claude
In news:,
____________________
Bonjour

Après une journée de recherche, je ne trouve pas pourquoi j'ai une
«erreur d'exécution '1004' : Erreur définie par l'application ou par
l'objet» après la deuxième instruction ci-après :

Sheets(6).Activate
ActiveSheet.Range(Cells(26, 10), Cells(117, 12)).Select

Merci d'avance



Chez moi celà fonctionne
--
A+
Jean-Claude
- Evitez lez gaz mous


Avatar
isabelle
bonjour luc,

ta macro est t'elle executé par un click sur un bouton de commande ?

isabelle

Bonjour

Après une journée de recherche, je ne trouve pas pourquoi j'ai une
«erreur d'exécution '1004' : Erreur définie par l'application ou par
l'objet» après la deuxième instruction ci-après :

Sheets(6).Activate
ActiveSheet.Range(Cells(26, 10), Cells(117, 12)).Select

Merci d'avance


Avatar
defluc
Voici la source:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim MaxVal, Rank, Score As Long
Dim i, j, FirstPlace, LastPlace, Col, ColHit, ScoreMax, Place,
NbrListes, Line As Integer
Dim Position, TmpStr As String
Dim ListToSort As Range

Rank = ActiveCell.Row
Position = ActiveCell.Address
LastPlace = 6
NbrCandid = 1
While ActiveSheet.Cells(LastPlace, 2) <> ""
LastPlace = LastPlace + 1
Wend
NbrCandid = LastPlace - 6
MaxVal = Application.WorksheetFunction.Max(Range(Cells(6, 4),
Cells(NbrCandid + 5, 4)))
ActiveSheet.ChartObjects("Graphique 1").Activate
ActiveChart.ChartArea.Select
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScale = -1 * MaxVal
.MaximumScale = 0
End With
LastPlace = LastPlace - 1
If Rank > 5 Then
Application.EnableEvents = False
FirstPlace = 1
TmpStr = "E6:E" + Trim(Str(LastPlace))
Range(TmpStr).ClearContents
ScoreMax = -100000000
CalcMinMax FirstPlace, LastPlace, ScoreMax
Place = 0
For j = FirstPlace To LastPlace + 1
For i = FirstPlace + 5 To LastPlace + 5
Line = Trim(Str(i))
Rank = Range("E" + Trim(Str(Line))).Value
Score = Range("D" + Trim(Str(Line))).Value
If Val(Rank) = 0 And Score = ScoreMax Then
Place = Place + 1
If Score > 0 Then Range("E" + Trim(Str(Line))).Value = Place
Exit For
End If
ScoreMax = -1000000000
CalcMinMax FirstPlace, LastPlace, ScoreMax
Next i
Next j
NbrListes = ActiveWorkbook.Sheets.Count - 4
ColHit = (NbrListes - 1) * 3 + 1
Sheets(6).Activate
ActiveSheet.Range(Cells(26, 10), Cells(117, 12)).Select
End If
Range(Position).Select
Application.EnableEvents = True
End Sub
Avatar
bourby
Si un graphique est actif, il ne reconnait pas Activesheet ???

Cordialement

Bourby



Voici la source:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim MaxVal, Rank, Score As Long
Dim i, j, FirstPlace, LastPlace, Col, ColHit, ScoreMax, Place,
NbrListes, Line As Integer
Dim Position, TmpStr As String
Dim ListToSort As Range

Rank = ActiveCell.Row
Position = ActiveCell.Address
LastPlace = 6
NbrCandid = 1
While ActiveSheet.Cells(LastPlace, 2) <> ""
LastPlace = LastPlace + 1
Wend
NbrCandid = LastPlace - 6
MaxVal = Application.WorksheetFunction.Max(Range(Cells(6, 4),
Cells(NbrCandid + 5, 4)))
ActiveSheet.ChartObjects("Graphique 1").Activate
ActiveChart.ChartArea.Select
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScale = -1 * MaxVal
.MaximumScale = 0
End With
LastPlace = LastPlace - 1
If Rank > 5 Then
Application.EnableEvents = False
FirstPlace = 1
TmpStr = "E6:E" + Trim(Str(LastPlace))
Range(TmpStr).ClearContents
ScoreMax = -100000000
CalcMinMax FirstPlace, LastPlace, ScoreMax
Place = 0
For j = FirstPlace To LastPlace + 1
For i = FirstPlace + 5 To LastPlace + 5
Line = Trim(Str(i))
Rank = Range("E" + Trim(Str(Line))).Value
Score = Range("D" + Trim(Str(Line))).Value
If Val(Rank) = 0 And Score = ScoreMax Then
Place = Place + 1
If Score > 0 Then Range("E" + Trim(Str(Line))).Value = Place
Exit For
End If
ScoreMax = -1000000000
CalcMinMax FirstPlace, LastPlace, ScoreMax
Next i
Next j
NbrListes = ActiveWorkbook.Sheets.Count - 4
ColHit = (NbrListes - 1) * 3 + 1
Sheets(6).Activate
ActiveSheet.Range(Cells(26, 10), Cells(117, 12)).Select
End If
Range(Position).Select
Application.EnableEvents = True
End Sub


Avatar
isabelle
re bonjour luc,

essai en deplacent la commande :
Application.EnableEvents = True

juste après la commande :
Next j

isabelle


Voici la source:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim MaxVal, Rank, Score As Long
Dim i, j, FirstPlace, LastPlace, Col, ColHit, ScoreMax, Place,
NbrListes, Line As Integer
Dim Position, TmpStr As String
Dim ListToSort As Range

Rank = ActiveCell.Row
Position = ActiveCell.Address
LastPlace = 6
NbrCandid = 1
While ActiveSheet.Cells(LastPlace, 2) <> ""
LastPlace = LastPlace + 1
Wend
NbrCandid = LastPlace - 6
MaxVal = Application.WorksheetFunction.Max(Range(Cells(6, 4),
Cells(NbrCandid + 5, 4)))
ActiveSheet.ChartObjects("Graphique 1").Activate
ActiveChart.ChartArea.Select
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScale = -1 * MaxVal
.MaximumScale = 0
End With
LastPlace = LastPlace - 1
If Rank > 5 Then
Application.EnableEvents = False
FirstPlace = 1
TmpStr = "E6:E" + Trim(Str(LastPlace))
Range(TmpStr).ClearContents
ScoreMax = -100000000
CalcMinMax FirstPlace, LastPlace, ScoreMax
Place = 0
For j = FirstPlace To LastPlace + 1
For i = FirstPlace + 5 To LastPlace + 5
Line = Trim(Str(i))
Rank = Range("E" + Trim(Str(Line))).Value
Score = Range("D" + Trim(Str(Line))).Value
If Val(Rank) = 0 And Score = ScoreMax Then
Place = Place + 1
If Score > 0 Then Range("E" + Trim(Str(Line))).Value = Place
Exit For
End If
ScoreMax = -1000000000
CalcMinMax FirstPlace, LastPlace, ScoreMax
Next i
Next j
NbrListes = ActiveWorkbook.Sheets.Count - 4
ColHit = (NbrListes - 1) * 3 + 1
Sheets(6).Activate
ActiveSheet.Range(Cells(26, 10), Cells(117, 12)).Select
End If
Range(Position).Select
Application.EnableEvents = True
End Sub