Macro Vba

M

Marc

Guest
Bonjour à tous
Je reviens vers vous car je patauge toujours (c'est ma première macro en vb)
La macro ci-dessous a été fournie par _Thierry (que je remercie)
Et j'essaie de faire fonctionner la 2eme macro à partir de la, mais ca ne fonctionne pas. Pouvez-vous me dire ou je commet une erreur
En vous en remerciant

Sub LookingForRedCell()
Dim FirstCell As Range
Dim Cell As Range
Dim Plage As Range
Dim i As Byte
For Each Cell In Range('B5:H10')
If Cell = Range('B1') Then
Set FirstCell = Cell
Exit For
End If
Next

If FirstCell Is Nothing Then
MsgBox 'Date ' & Range('B1') & ' non trouvée, procédure avortée', vbCritical
Exit Sub
End If
Set Plage = Range(FirstCell.Offset(1, 0), ActiveCell.Offset(98, 0))
Clignotement
End Sub

Public Sub Clignotement()
Dim Tempo As Date
Dim Cell As Range
Static C As Boolean
C = Not C
Tempo = Now + TimeValue('00:00:01')
Range.FirstCell = Cell
Application.OnTime Tempo, 'Clignotement'
End Sub

Public Sub StopClign()
Dim Tempo
Dim Cell As Range
Application.OnTime Tempo, 'Clignotement', , False
Range.FirstCell = Cell
End Sub
 

Charly2

Nous a quittés en 2006
Repose en paix
Bonsoir Marc, le forum,

Je suis désolé que tu n'aies pas obtenu de réponse, mais nous n'avons qu'une partie de ton code...
J'y vois des affectations d'objets non initialisés au préalable, par exemple, que souhaites-tu faire en écrivant Range.FirstCell = Cell ???

Peut-être pourrais-tu poser le problème différemment, non ?

Amicalement
Charly
 
M

Marc

Guest
Bonsoir Charly et merci à toi

Voici la macro de _Thierry

Option Explicit
Declare Sub Sleep Lib 'kernel32' (ByVal dwMilliseconds As Long)

Sub LookingForRedCell()
Dim FirstCell As Range
Dim Cell As Range
Dim Plage As Range
Dim i As Byte

For Each Cell In Range('B5:H90')
If Cell = Range('B1') Then
Set FirstCell = Cell
Exit For
End If
Next

If FirstCell Is Nothing Then
MsgBox 'Date ' & Range('B1') & ' non trouvée, procédure avortée', vbCritical
Exit Sub
End If

Set Plage = Range(FirstCell.Offset(1, 0), ActiveCell.Offset(98, 0))

For Each Cell In Plage
If Cell.Interior.ColorIndex = 3 Then
Cell.Activate
For i = 1 To 10
Sleep (100)
Cell.Interior.ColorIndex = 6
Sleep (100)
Cell.Interior.ColorIndex = 3
Next i
Exit For
End If
Next

End Sub

et voici (a peu près) la macro que je désire incorporer

Public OrigBkgCol As Long, OrigTxtCol As Long
Public OldCell As Range
Sub InitFlash()
Set OldCell = ActiveCell
OrigBkgCol = ActiveCell.Interior.ColorIndex
OrigTxtCol = ActiveCell.Font.ColorIndex
Application.OnTime Now + TimeValue('00:00:01'), 'Flash'
End Sub

le but étant que la cellule (aléatoire dans la plage donnée) clignote soit :
pendant 30 mi,utes, soit tant que la couleur de fond de la cellule est rouge.
Y ajouter une procédure de fin au cas ou aucune cellule n'aurait de fond rouge. En espérant m'être fait comprendre, je te remercie de te pencher sur mon prob.
Marc
 

Discussions similaires

Réponses
6
Affichages
202

Statistiques des forums

Discussions
311 730
Messages
2 081 989
Membres
101 856
dernier inscrit
Marina40