jjmermen
Gebruiker
- Lid geworden
- 23 okt 2012
- Berichten
- 57
- Besturingssysteem
- Windows
- Office versie
- 365
In deze VBA code wil ik graag wil dat de code alleen in een bepaald bereik werkt. Bijvoorbeeld in het bereik B7:AV500. Is dat mogelijk?
In de rijen 1 t/m 5 heb ik namelijk opmaak zitten die ik niet kwijt wil. De VBA code die ik nu heb maakt alle bestaande opmaak leeg.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
' Clear the color of all the cells
Cells.Interior.ColorIndex = 0
With Target
' Highlight the entire row that contain the active cell
.EntireRow.Interior.ColorIndex = 19
' Highlight the active cell
Target.Interior.ColorIndex = 6
End With
Application.ScreenUpdating = True
End Sub
In de rijen 1 t/m 5 heb ik namelijk opmaak zitten die ik niet kwijt wil. De VBA code die ik nu heb maakt alle bestaande opmaak leeg.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Application.ScreenUpdating = False
' Clear the color of all the cells
Cells.Interior.ColorIndex = 0
With Target
' Highlight the entire row that contain the active cell
.EntireRow.Interior.ColorIndex = 19
' Highlight the active cell
Target.Interior.ColorIndex = 6
End With
Application.ScreenUpdating = True
End Sub