Thema Datum  Von Nutzer Rating
Antwort
10.08.2020 10:05:39 Andreas
NotSolved
10.08.2020 15:13:16 jofed
NotSolved
10.08.2020 15:28:21 Andreas
NotSolved
10.08.2020 19:54:37 ralf_b
NotSolved
11.08.2020 09:56:31 Gast58170
NotSolved
11.08.2020 13:07:11 Gast53152
NotSolved
Rot Pfeil Symbol bei bestimmten Zellen
11.08.2020 13:56:25 Gast9065
NotSolved
11.08.2020 14:38:53 Gast9437
NotSolved
11.08.2020 17:55:30 Andreas
NotSolved
11.08.2020 23:52:57 Gast70598
*****
Solved
12.08.2020 06:41:35 Andreas
NotSolved
12.08.2020 08:18:58 volti,
NotSolved

Ansicht des Beitrags:
Von:
Gast9065
Datum:
11.08.2020 13:56:25
Views:
568
Rating: Antwort:
  Ja
Thema:
Pfeil Symbol bei bestimmten Zellen
Hallo Andreas,
 
hier schon mal der erste Teil des Codes zum Realsieren Deines Vorhabens.

Die Function ermittelt die Bildschirmkoordinaten zum angegebenen Range. Die Test-Sub könntest Du einem SelectionChange-Event zuordnnen, dann siehst Du, dass sich der Cursor ändern, wenn das aktive Feld unter der Maus liegt.

Fehlt jetzt nur noch der Teil mit dem Timer....

Option Explicit

Private Declare PtrSafe Function WindowFromPoint Lib "user32" ( _
        ByVal xPoint As Long, ByVal yPoint As Long) As LongPtr
Private Declare PtrSafe Function GetWindowRect Lib "user32" ( _
        ByVal hWnd As LongPtr, lpRect As RECT) As Long
Private Declare PtrSafe Function SetCursorPos Lib "user32" ( _
        ByVal x As Long, ByVal y As Long) As Long
Private Declare PtrSafe Function GetCursorPos Lib "user32" ( _
        lpPoint As POINTAPI) As Long
Private Declare PtrSafe Function GetClientRect Lib "user32" ( _
        ByVal hWnd As LongPtr, lpRect As RECT) As Long
Private Declare PtrSafe Function ClientToScreen Lib "user32" ( _
        ByVal hWnd As LongPtr, lpPoint As POINTAPI) As Long
        
Private Type POINTAPI
  x As Long
  y As Long
End Type

Private Type RECT
  Left    As Long
  Top     As Long
  Right   As Long
  Bottom  As Long
End Type


Sub Test_SetzeMauscursor()
 Dim RECT1 As RECT, Pt As POINTAPI
 XlsPos2ScreenPos RECT1
 With RECT1
   GetCursorPos Pt
   If Pt.x > .Left And Pt.y > .Top And Pt.x < (.Left + .Right) And Pt.y < (.Top + .Bottom) Then
     Application.Cursor = xlNorthwestArrow
   Else
     Application.Cursor = xlDefault
   End If
 End With
   
End Sub


Function XlsPos2ScreenPos(tCRect As RECT) As Boolean
'Ermittelt die Screenpixelposition für die linke, obere Ecke eines Excelrange
 Dim Pt As POINTAPI, cZoom As Currency
 Dim Px As Long, Py As Long, i As Integer
 cZoom = ActiveWindow.Zoom * 0.016666666
 GetClientRect Application.hWnd, tCRect
 Pt.x = tCRect.Left:  Pt.y = tCRect.Top
 ClientToScreen Application.hWnd, Pt
 Px = Pt.x
 Py = Pt.y + CommandBars("Ribbon").Controls(1).Height
 If Application.DisplayFormulaBar = True Then _
  Py = Py + 15 + 24 * Application.FormulaBarHeight + 15
 With ActiveWindow
  If .DisplayHeadings = True Then
     Px = Px + 0.37 * .Zoom
     Py = Py + 0.23 * .Zoom
  End If
  Px = Px + Selection.Left * cZoom
  For i = 1 To Selection.Column
    If i < .ScrollColumn Then _
       Px = Px - Columns(i).Width * cZoom
  Next i
  Py = Py + Selection.Top * cZoom
  For i = 1 To Selection.Row
    If i < .ScrollRow Then _
       Py = Py - Rows(i).Height * cZoom
  Next i
 End With
 With tCRect
   .Left = Px - 1: .Top = Py - 1
   .Right = Selection.Width * cZoom
   .Bottom = Selection.Height * cZoom
 End With

End Function

Viele Grüße

Karl-Heinz


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
10.08.2020 10:05:39 Andreas
NotSolved
10.08.2020 15:13:16 jofed
NotSolved
10.08.2020 15:28:21 Andreas
NotSolved
10.08.2020 19:54:37 ralf_b
NotSolved
11.08.2020 09:56:31 Gast58170
NotSolved
11.08.2020 13:07:11 Gast53152
NotSolved
Rot Pfeil Symbol bei bestimmten Zellen
11.08.2020 13:56:25 Gast9065
NotSolved
11.08.2020 14:38:53 Gast9437
NotSolved
11.08.2020 17:55:30 Andreas
NotSolved
11.08.2020 23:52:57 Gast70598
*****
Solved
12.08.2020 06:41:35 Andreas
NotSolved
12.08.2020 08:18:58 volti,
NotSolved