Tasten F1-F5 belegen statt CommanButton
26.06.2022 15:06:02
Nader
folgender Code ist für den Aufruf einer Menümaske vorhanden:
Option Explicit
Private Sub UserForm_Terminate()
Call StopTimer
End Sub
Private Sub CommandButton4_Click()
UserForm3.Show
End Sub
Private Sub CommandButton6_Click()
UF_Dienstprogramme.Show
End Sub
Private Sub WorkSheet_Change(ByVal Target As Range)
Application.EnableEvents = False
ThisWorkbook.RefreshAll
Application.EnableEvents = True
End Sub
Private Sub CommandButton1_Click()
UF_VB_Aufnehmen.Show
End Sub
Private Sub CommandButton2_Click()
UserForm2.Show
End Sub
Private Sub CommandButton5_Click()
Unload UF_Menü
End Sub
Private Sub UserForm_Initialize()
Label2.Caption = Date
Call RunTimer
Application.WindowState = xlMaximized
With Me
.Height = Application.Height
.Width = Application.Width
End With
'Anzeigen ListBox1
Dim lLetzte1 As Long
Application.ScreenUpdating = False
ListBox1.Clear
With Worksheets("Tabelle1")
lLetzte1 = .Cells(Rows.Count, 1).End(xlUp).Row
With Me.ListBox1
.ColumnCount = 11
' ListBox1.Selected(0) = True
.ColumnHeads = False
.Font.Size = 18
ListBox1.RowSource = "Tabelle1!A2:K2" & lLetzte1
'.Height = .ListCount * .Font.Size * 2.5
End With
End With
Application.ScreenUpdating = True
ListBox1.ColumnWidths = "3,4 Cm;0,5 Cm;2,3 Cm;2,5 Cm;4,5 Cm;4,5 Cm;6,0 Cm;6,0 Cm;8,5 Cm;9,0 Cm;1,5 Cm"
'Anzeigen ListBox1
Dim lLetzte2 As Long
Application.ScreenUpdating = False
ListBox2.Clear
With Range("Tabelle1!A1:K1")
With Worksheets("Tabelle1")
lLetzte2 = .Cells(Rows.Count, 1).End(xlUp).Row
With Me.ListBox2
.ColumnCount = 11
' ListBox1.Selected(0) = True
.ColumnHeads = False
.Font.Size = 18
ListBox2.RowSource = "Tabelle1!A1:K1" & lLetzte2
'.Height = .ListCount * .Font.Size * 2.5
End With
End With
Application.ScreenUpdating = True
ListBox2.ColumnWidths = "3,4 Cm;0,5 Cm;2,3 Cm;2,5 Cm;4,5 Cm;4,5 Cm;6,0 Cm;6,0 Cm;8,5 Cm;9,0 Cm;1,5 Cm"
End With
End Sub
Private Sub CommandButton3_Click()
Dim C As Variant
Dim i As Long
If Me.ListBox1.ListCount > 0 Then
If MsgBox("Die markierten Daten werden aus der Activen Vorbestellungsliste gelöscht." & vbLf & _
"Wollen Sie fortfahren?", vbYesNo + vbQuestion, "Achtung!") = vbYes Then
For i = UF_Menü.ListBox1.ListCount - 1 To 0 Step -1
If Me.ListBox1.Selected(i) = True Then
With Sheets("Tabelle1")
.Rows(i + 2).Delete Shift:=xlUp
End With
Set C = Nothing
End If
Next i
End If
End If
End Sub
Nun möchte ich für den Aufruf von Subroutinen nicht wie sonst die Command Buttons benutzen, sondern zum Aufrufen die Funktionstasten (F1 bis F5) belegen.Ich habe auch schon sehr mit Application.OnKey und andere Varianten experimentiert, leider mit keinem so großen Erfolg.
Wenn mir jemand vielleicht einen Lösungsweg vorschlagen könnte, wäre ich sehr dankbar!
Ich danke euch im Voraus
Viele liebe Grüße
Nader