Beste forumleden,
Is het mogelijk om onderstaande routine te versimpelen?
In mijn bestand wil ik namelijk ongeveer 500 buttons gaan programmeren
Private Sub CommandButton0001_Click()
Dim ip, f As Range
ip = ("0001")
If ip <> "" Then
Set f = Sheets("LRH").Cells.Find(ip, , , xlWhole)
If Not f Is Nothing Then
With Application
.Goto f.Parent.Cells(.Max(1, f.Row - .RoundDown(ActiveWindow.VisibleRange.Rows.Count / 2, 0)), .Max(1, f.Column - .RoundDown(ActiveWindow.VisibleRange.Columns.Count / 2, 0))), True
.Goto f
End With
End If
End If
End Sub
Private Sub CommandButton0002_Click()
Dim ip, f As Range
ip = ("0002")
If ip <> "" Then
Set f = Sheets("LRH").Cells.Find(ip, , , xlWhole)
If Not f Is Nothing Then
With Application
.Goto f.Parent.Cells(.Max(1, f.Row - .RoundDown(ActiveWindow.VisibleRange.Rows.Count / 2, 0)), .Max(1, f.Column - .RoundDown(ActiveWindow.VisibleRange.Columns.Count / 2, 0))), True
.Goto f
End With
End If
End If
End Sub
Private Sub CommandButton0003_Click()
Dim ip, f As Range
ip = ("0003")
If ip <> "" Then
Set f = Sheets("LRH").Cells.Find(ip, , , xlWhole)
If Not f Is Nothing Then
With Application
.Goto f.Parent.Cells(.Max(1, f.Row - .RoundDown(ActiveWindow.VisibleRange.Rows.Count / 2, 0)), .Max(1, f.Column - .RoundDown(ActiveWindow.VisibleRange.Columns.Count / 2, 0))), True
.Goto f
End With
End If
End If
End Sub
Enzovoort.
Alvast bedankt voor jullie moeite
Is het mogelijk om onderstaande routine te versimpelen?
In mijn bestand wil ik namelijk ongeveer 500 buttons gaan programmeren
Private Sub CommandButton0001_Click()
Dim ip, f As Range
ip = ("0001")
If ip <> "" Then
Set f = Sheets("LRH").Cells.Find(ip, , , xlWhole)
If Not f Is Nothing Then
With Application
.Goto f.Parent.Cells(.Max(1, f.Row - .RoundDown(ActiveWindow.VisibleRange.Rows.Count / 2, 0)), .Max(1, f.Column - .RoundDown(ActiveWindow.VisibleRange.Columns.Count / 2, 0))), True
.Goto f
End With
End If
End If
End Sub
Private Sub CommandButton0002_Click()
Dim ip, f As Range
ip = ("0002")
If ip <> "" Then
Set f = Sheets("LRH").Cells.Find(ip, , , xlWhole)
If Not f Is Nothing Then
With Application
.Goto f.Parent.Cells(.Max(1, f.Row - .RoundDown(ActiveWindow.VisibleRange.Rows.Count / 2, 0)), .Max(1, f.Column - .RoundDown(ActiveWindow.VisibleRange.Columns.Count / 2, 0))), True
.Goto f
End With
End If
End If
End Sub
Private Sub CommandButton0003_Click()
Dim ip, f As Range
ip = ("0003")
If ip <> "" Then
Set f = Sheets("LRH").Cells.Find(ip, , , xlWhole)
If Not f Is Nothing Then
With Application
.Goto f.Parent.Cells(.Max(1, f.Row - .RoundDown(ActiveWindow.VisibleRange.Rows.Count / 2, 0)), .Max(1, f.Column - .RoundDown(ActiveWindow.VisibleRange.Columns.Count / 2, 0))), True
.Goto f
End With
End If
End If
End Sub
Enzovoort.
Alvast bedankt voor jullie moeite