bowlingman
Gebruiker
- Lid geworden
- 17 okt 2007
- Berichten
- 433
Ik heb een file waarin,als cel B3 wijzigt, automatisch een aantal rijen naar beneden wordt gescrold.
Kan je de volgende code ook korter schrijven
Kan je de volgende code ook korter schrijven
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("B3").Value = "1" Then
ActiveWindow.ScrollRow = 4
End If
If Range("B3").Value = "2" Then
ActiveWindow.ScrollRow = 19
End If
If Range("B3").Value = "3" Then
ActiveWindow.ScrollRow = 34
End If
If Range("B3").Value = "4" Then
ActiveWindow.ScrollRow = 49
End If
If Range("B3").Value = "5" Then
ActiveWindow.ScrollRow = 64
End If
If Range("B3").Value = "6" Then
ActiveWindow.ScrollRow = 79
End If
If Range("B3").Value = "7" Then
ActiveWindow.ScrollRow = 94
End If
If Range("B3").Value = "8" Then
ActiveWindow.ScrollRow = 109
End If
If Range("B3").Value = "9" Then
ActiveWindow.ScrollRow = 124
End If
If Range("B3").Value = "10" Then
ActiveWindow.ScrollRow = 139
End If
If Range("B3").Value = "11" Then
ActiveWindow.ScrollRow = 154
End If
If Range("B3").Value = "12" Then
ActiveWindow.ScrollRow = 169
End If
If Range("B3").Value = "13" Then
ActiveWindow.ScrollRow = 184
End If
If Range("B3").Value = "14" Then
ActiveWindow.ScrollRow = 199
End If
If Range("B3").Value = "15" Then
ActiveWindow.ScrollRow = 214
End If
If Range("B3").Value = "16" Then
ActiveWindow.ScrollRow = 229
End If
If Range("B3").Value = "17" Then
ActiveWindow.ScrollRow = 244
End If
If Range("B3").Value = "18" Then
ActiveWindow.ScrollRow = 259
End If
If Range("B3").Value = "19" Then
ActiveWindow.ScrollRow = 274
End If
If Range("B3").Value = "20" Then
ActiveWindow.ScrollRow = 289
End If
If Range("B3").Value = "21" Then
ActiveWindow.ScrollRow = 304
End If
If Range("B3").Value = "22" Then
ActiveWindow.ScrollRow = 319
End If
If Range("B3").Value = "23" Then
ActiveWindow.ScrollRow = 334
End If
If Range("B3").Value = "24" Then
ActiveWindow.ScrollRow = 349
End If
If Range("B3").Value = "25" Then
ActiveWindow.ScrollRow = 364
End If
If Range("B3").Value = "26" Then
ActiveWindow.ScrollRow = 379
End If
End Sub