Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Mise en forme conditionnelle

7 réponses
Avatar
Clochard
Bonsoir,

J'aimerais bien savoir si lorsque je place mon curseur sur F5 les cellules
contenant "Pertes" dans A1:B10 deviennent automatiquement rouge....
Juste en me positionnant sur la cellule F5 ?

Est-ce possible ?
Merci

--
Clochard
Aimerais bien savoir....
Merci!

7 réponses

Avatar
Daniel.C
Bonjour.
C'est possible, avec une macro, si tu cliques sur F5. Si c'est ce que tu
veux, dis-le.
Cordialement.
Daniel
"Clochard" a écrit dans le message de news:

Bonsoir,

J'aimerais bien savoir si lorsque je place mon curseur sur F5 les cellules
contenant "Pertes" dans A1:B10 deviennent automatiquement rouge....
Juste en me positionnant sur la cellule F5 ?

Est-ce possible ?
Merci

--
Clochard
Aimerais bien savoir....
Merci!


Avatar
Daniel.C
Tu peux aussi monitorer la position du curseur et celle de la cellule, mais
c'est très pénalisant.
Daniel
"Clochard" a écrit dans le message de news:

Bonsoir,

J'aimerais bien savoir si lorsque je place mon curseur sur F5 les cellules
contenant "Pertes" dans A1:B10 deviennent automatiquement rouge....
Juste en me positionnant sur la cellule F5 ?

Est-ce possible ?
Merci

--
Clochard
Aimerais bien savoir....
Merci!


Avatar
Clochard
Merci Daniel....

Donc... je fouille....

Clochard
Merci!



Tu peux aussi monitorer la position du curseur et celle de la cellule, mais
c'est très pénalisant.
Daniel
"Clochard" a écrit dans le message de news:

Bonsoir,

J'aimerais bien savoir si lorsque je place mon curseur sur F5 les cellules
contenant "Pertes" dans A1:B10 deviennent automatiquement rouge....
Juste en me positionnant sur la cellule F5 ?

Est-ce possible ?
Merci

--
Clochard
Aimerais bien savoir....
Merci!







Avatar
Clochard
Non Daniel...
Ce n'est pas lorsque je clique sur F5... c'est lorsque je suis positionné
dans une cellule quelconque simplement....
--
Clochard
Aimerais bien savoir....
Merci!



Bonjour.
C'est possible, avec une macro, si tu cliques sur F5. Si c'est ce que tu
veux, dis-le.
Cordialement.
Daniel
"Clochard" a écrit dans le message de news:

Bonsoir,

J'aimerais bien savoir si lorsque je place mon curseur sur F5 les cellules
contenant "Pertes" dans A1:B10 deviennent automatiquement rouge....
Juste en me positionnant sur la cellule F5 ?

Est-ce possible ?
Merci

--
Clochard
Aimerais bien savoir....
Merci!







Avatar
Modeste
Bonsour® Clochard avec ferveur ;o))) vous nous disiez :

J'aimerais bien savoir si lorsque je place mon curseur sur F5 les
cellules contenant "Pertes" dans A1:B10 deviennent automatiquement
rouge....
Juste en me positionnant sur la cellule F5 ?
Est-ce possible ?


que se passe-t-il lorsque l'on quitte le positionnement ???
que se passe-t-il si les cellules ont déja une couleur autre que rouge ???
si la couleur rouge reste, attention lors des recalculs, la couleur rouge ne
sera pas effacée

sur la cellule F5
Positionner un label issu de la boite à outils Controles
Propriete Backstyle=0

Private Sub Label1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer,
ByVal X As Single, ByVal Y As Single)
For Each cell In Range("A1:B10")
If cell.Value ="Pertes" Then cell.Interior.Color = vbRed Else
cell.Interior.Color = xlNone
Next
End Sub


AMHA une MEFC est préférable ...






--
--
@+
;o)))

Avatar
Daniel.C
J'ai un peu fouillé; j'ai trouvé ceci qui affiche dans la barre d'état la
position du curseur :
Dans un premier module :

Option Explicit


Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long


Private Declare Function SetTimer Lib "user32" _
(ByVal hWnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long


Private Declare Function KillTimer Lib "user32" _
(ByVal hWnd As Long, _
ByVal nIDEvent As Long) As Long


Private Declare Function GetCurrentVbaProject Lib "vba332.dll" _
Alias "EbGetExecutingProj" _
(hProject As Long) As Long


Private Declare Function GetFuncID Lib "vba332.dll" _
Alias "TipGetFunctionId" _
(ByVal hProject As Long, _
ByVal strFunctionName As String, _
ByRef strFunctionID As String) As Long


Private Declare Function GetAddr Lib "vba332.dll" _
Alias "TipGetLpfnOfFunctionId" _
(ByVal hProject As Long, _
ByVal strFunctionID As String, _
ByRef lpfnAddressOf As Long) As Long


Private WindowsTimer As Long


Public Function fncWindowsTimer(TimeInterval As Long) As Boolean
Dim WindowsTimer As Long
WindowsTimer = 0
'if we are in Excel2000 or above use the
'built-in AddressOf operator to get a pointer to the
'callback function
If Val(Application.Version) > 8 Then
WindowsTimer = SetTimer(hWnd:=FindWindow("XLMAIN", _
Application.Caption), _
nIDEvent:=0, _
uElapse:=TimeInterval, _
lpTimerFunc:­drOf_cbkCustomTimer)
Else 'use K.Getz & M.Kaplan function to get a pointer
WindowsTimer = SetTimer(hWnd:=FindWindow("XLMAIN", _
Application.Caption), _
nIDEvent:=0, _
uElapse:=TimeInterval, _
lpTimerFunc:­drOf("cbkCustomTimer"))
End If


fncWindowsTimer = CBool(WindowsTimer)


End Function


Public Function fncStopWindowsTimer()
KillTimer hWnd:=FindWindow("XLMAIN", Application.Caption), _
nIDEvent:=WindowsTimer
End Function


Private Function cbkCustomTimer(ByVal Window_hWnd As Long, _
ByVal WindowsMessage As Long, _
ByVal EventID As Long, _
ByVal SystemTime As Long) As Long


On Error Resume Next


ShowPosition


End Function


Private Function AddrOf(CallbackFunctionName As String) As Long
'AddressOf operator replacement for Office97 VBA
'Authors: Ken Getz and Michael Kaplan
Dim aResult As Long
Dim CurrentVBProject As Long
Dim strFunctionID As String
Dim AddressOfFunction As Long
Dim UnicodeFunctionName As String


'convert the name of the function to Unicode system
UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode)


'if the current VBProjects exists...
If Not GetCurrentVbaProject(CurrentVBProject) = 0 Then
'...get the function ID of the callback function, based on its
'unicode-converted name, in order to ensure that it exists
aResult = GetFuncID(hProject:=CurrentVBProject, _
strFunctionName:=UnicodeFunctionName, _
strFunctionID:=strFunctionID)
'if the function exists indeed ...
If aResult = 0 Then
'...get a pointer to the callback function based on
'the strFunctionID argument of the GetFuncID function
aResult = GetAddr(hProject:=CurrentVBProject, _
strFunctionID:=strFunctionID, _
lpfnAddressOf:­dressOfFunction)
'if we've got the pointer pass it to the result of the function
If aResult = 0 Then
AddrOf = AddressOfFunction
End If


End If


End If


End Function


Private Function AddrOf_cbkCustomTimer() As Long
'Office97 VBE does not recognise the AddressOf operator;
'however, it does not raise a compile-error either...
AddrOf_cbkCustomTimer = vbaPass(AddressOf cbkCustomTimer)
End Function


Private Function vbaPass(AddressOfFunction As Long) As Long
vbaPass = AddressOfFunction
End Function

*********
Dans un second module :

Option Explicit


Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long


Private Type POINTAPI
x As Long
y As Long
End Type


Private oldStatusBar


Sub StartDisplay()
oldStatusBar = Application.DisplayStatusBar
Application.DisplayStatusBar = True
fncWindowsTimer 1000
End Sub


Sub StopDisplay()
fncStopWindowsTimer
Application.StatusBar = False
Application.DisplayStatusBar = oldStatusBar
End Sub


Function Timer(time As Long)
Timer = "Time up!"
End Function


Public Sub ShowPosition()
Dim pPosition As POINTAPI
Dim lReturn As Long


lReturn = GetCursorPos(pPosition)
Application.StatusBar = "x co-ordinate: " & pPosition.x & ", y co-ordinate:
" & pPosition.y



End Sub

Pour démarrer l'affichage, exécute la macro StartDisplay et pour arrêter, la
macro StopDisplay.
Ca fonctionne à condition que tu ne déplace pas le curseur trop vite.
Il ne reste plus qu'à trouver l'emplacement et la taille de la cellule, de
déterminer les déplacements de cellule et de taille de cellule et de
comparer avec la position du curseur.
Daniel
"Clochard" a écrit dans le message de news:

Merci Daniel....

Donc... je fouille....

Clochard
Merci!



Tu peux aussi monitorer la position du curseur et celle de la cellule,
mais
c'est très pénalisant.
Daniel
"Clochard" a écrit dans le message de news:

Bonsoir,

J'aimerais bien savoir si lorsque je place mon curseur sur F5 les
cellules
contenant "Pertes" dans A1:B10 deviennent automatiquement rouge....
Juste en me positionnant sur la cellule F5 ?

Est-ce possible ?
Merci

--
Clochard
Aimerais bien savoir....
Merci!









Avatar
Clochard
Merci Daniel,
Pour le temps que tu as mis afin de m'aider a solutionner mon problème....

Je tente de tout mettre ça en place... en tout cas....
--
Clochard
Merci!



J'ai un peu fouillé; j'ai trouvé ceci qui affiche dans la barre d'état la
position du curseur :
Dans un premier module :

Option Explicit


Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long


Private Declare Function SetTimer Lib "user32" _
(ByVal hWnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long


Private Declare Function KillTimer Lib "user32" _
(ByVal hWnd As Long, _
ByVal nIDEvent As Long) As Long


Private Declare Function GetCurrentVbaProject Lib "vba332.dll" _
Alias "EbGetExecutingProj" _
(hProject As Long) As Long


Private Declare Function GetFuncID Lib "vba332.dll" _
Alias "TipGetFunctionId" _
(ByVal hProject As Long, _
ByVal strFunctionName As String, _
ByRef strFunctionID As String) As Long


Private Declare Function GetAddr Lib "vba332.dll" _
Alias "TipGetLpfnOfFunctionId" _
(ByVal hProject As Long, _
ByVal strFunctionID As String, _
ByRef lpfnAddressOf As Long) As Long


Private WindowsTimer As Long


Public Function fncWindowsTimer(TimeInterval As Long) As Boolean
Dim WindowsTimer As Long
WindowsTimer = 0
'if we are in Excel2000 or above use the
'built-in AddressOf operator to get a pointer to the
'callback function
If Val(Application.Version) > 8 Then
WindowsTimer = SetTimer(hWnd:=FindWindow("XLMAIN", _
Application.Caption), _
nIDEvent:=0, _
uElapse:=TimeInterval, _
lpTimerFunc:­drOf_cbkCustomTimer)
Else 'use K.Getz & M.Kaplan function to get a pointer
WindowsTimer = SetTimer(hWnd:=FindWindow("XLMAIN", _
Application.Caption), _
nIDEvent:=0, _
uElapse:=TimeInterval, _
lpTimerFunc:­drOf("cbkCustomTimer"))
End If


fncWindowsTimer = CBool(WindowsTimer)


End Function


Public Function fncStopWindowsTimer()
KillTimer hWnd:=FindWindow("XLMAIN", Application.Caption), _
nIDEvent:=WindowsTimer
End Function


Private Function cbkCustomTimer(ByVal Window_hWnd As Long, _
ByVal WindowsMessage As Long, _
ByVal EventID As Long, _
ByVal SystemTime As Long) As Long


On Error Resume Next


ShowPosition


End Function


Private Function AddrOf(CallbackFunctionName As String) As Long
'AddressOf operator replacement for Office97 VBA
'Authors: Ken Getz and Michael Kaplan
Dim aResult As Long
Dim CurrentVBProject As Long
Dim strFunctionID As String
Dim AddressOfFunction As Long
Dim UnicodeFunctionName As String


'convert the name of the function to Unicode system
UnicodeFunctionName = StrConv(CallbackFunctionName, vbUnicode)


'if the current VBProjects exists...
If Not GetCurrentVbaProject(CurrentVBProject) = 0 Then
'...get the function ID of the callback function, based on its
'unicode-converted name, in order to ensure that it exists
aResult = GetFuncID(hProject:=CurrentVBProject, _
strFunctionName:=UnicodeFunctionName, _
strFunctionID:=strFunctionID)
'if the function exists indeed ...
If aResult = 0 Then
'...get a pointer to the callback function based on
'the strFunctionID argument of the GetFuncID function
aResult = GetAddr(hProject:=CurrentVBProject, _
strFunctionID:=strFunctionID, _
lpfnAddressOf:­dressOfFunction)
'if we've got the pointer pass it to the result of the function
If aResult = 0 Then
AddrOf = AddressOfFunction
End If


End If


End If


End Function


Private Function AddrOf_cbkCustomTimer() As Long
'Office97 VBE does not recognise the AddressOf operator;
'however, it does not raise a compile-error either...
AddrOf_cbkCustomTimer = vbaPass(AddressOf cbkCustomTimer)
End Function


Private Function vbaPass(AddressOfFunction As Long) As Long
vbaPass = AddressOfFunction
End Function

*********
Dans un second module :

Option Explicit


Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long


Private Type POINTAPI
x As Long
y As Long
End Type


Private oldStatusBar


Sub StartDisplay()
oldStatusBar = Application.DisplayStatusBar
Application.DisplayStatusBar = True
fncWindowsTimer 1000
End Sub


Sub StopDisplay()
fncStopWindowsTimer
Application.StatusBar = False
Application.DisplayStatusBar = oldStatusBar
End Sub


Function Timer(time As Long)
Timer = "Time up!"
End Function


Public Sub ShowPosition()
Dim pPosition As POINTAPI
Dim lReturn As Long


lReturn = GetCursorPos(pPosition)
Application.StatusBar = "x co-ordinate: " & pPosition.x & ", y co-ordinate:
" & pPosition.y



End Sub

Pour démarrer l'affichage, exécute la macro StartDisplay et pour arrêter, la
macro StopDisplay.
Ca fonctionne à condition que tu ne déplace pas le curseur trop vite.
Il ne reste plus qu'à trouver l'emplacement et la taille de la cellule, de
déterminer les déplacements de cellule et de taille de cellule et de
comparer avec la position du curseur.
Daniel
"Clochard" a écrit dans le message de news:

Merci Daniel....

Donc... je fouille....

Clochard
Merci!



Tu peux aussi monitorer la position du curseur et celle de la cellule,
mais
c'est très pénalisant.
Daniel
"Clochard" a écrit dans le message de news:

Bonsoir,

J'aimerais bien savoir si lorsque je place mon curseur sur F5 les
cellules
contenant "Pertes" dans A1:B10 deviennent automatiquement rouge....
Juste en me positionnant sur la cellule F5 ?

Est-ce possible ?
Merci

--
Clochard
Aimerais bien savoir....
Merci!