- Katılım
- 12 Ağustos 2007
- Mesajlar
- 301
- Excel Vers. ve Dili
-
2003 türkçe
2016 türkçe
Merhabalar arama yapmadığım sanılmasın. Bu başlık altında onlarca kod buldum. Ancak hanigi satırın ne işe yaradığını bilmediğimden yardıma ihtiyacım var.
1- Aşağıdaki kod gayet güzel ama renklendirdiği satır ve sütunların sınırı yok. sayfa içinde nereye tıklasam çalışıyor. Onu tablo boyutunda nasıl sınırlandırabilirim. Mesela D3:AG50 aralığındaki bir tablo için. Renkler tablo dışına taşmamalı.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Satır As Range, Sütun As Range
Set Satır = Range(Cells(ActiveCell.Row, 1), Cells(ActiveCell.Row, 256))
Set Sütun = Range(Cells(1, ActiveCell.Column), Cells(65536, ActiveCell.Column))
Cells.FormatConditions.Delete
With Satır
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:=1
.FormatConditions(1).Font.Bold = True
.FormatConditions(1).Interior.ColorIndex = 8
End With
With Sütun
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:=1
.FormatConditions(1).Font.Bold = True
.FormatConditions(1).Interior.ColorIndex = 8
End With
With ActiveCell
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:=1
.FormatConditions(1).Font.Bold = True
.FormatConditions(1).Interior.ColorIndex = 6
End With
2- Satır ve sütun renklendirmeleri aktif hücreye kadar olan aşağıdaki koda nasıl bir ekleme yapılırsa yukarıdaki gibi sayfadaki diğer renkleri silmez.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim oRow As String
Dim oCol As String
Dim DataRg As Range
Dim A As Range
Dim AllRg As Range
Set DataRg = Range("B2:Ah1000")
Set AllRg = Range("A1:Ah1000")
If Target.Cells.Count > 1 Then Exit Sub
If Not Application.Intersect(Target, DataRg) Is Nothing Then
AllRg.Interior.ColorIndex = xlNone
oRow = "A" & Target.Row & ":" & Target.Offset(0, -1).Address
oCol = Target.Offset(1 - Target.Row, 0).Address & ":" & Target.Offset(-1, 0).Address
Range(oRow).Interior.ColorIndex = 10
Range(oCol).Interior.ColorIndex = 17
Else
AllRg.Interior.ColorIndex = xlNone
End If
End Sub
Şimdiden teşekkürler
1- Aşağıdaki kod gayet güzel ama renklendirdiği satır ve sütunların sınırı yok. sayfa içinde nereye tıklasam çalışıyor. Onu tablo boyutunda nasıl sınırlandırabilirim. Mesela D3:AG50 aralığındaki bir tablo için. Renkler tablo dışına taşmamalı.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Satır As Range, Sütun As Range
Set Satır = Range(Cells(ActiveCell.Row, 1), Cells(ActiveCell.Row, 256))
Set Sütun = Range(Cells(1, ActiveCell.Column), Cells(65536, ActiveCell.Column))
Cells.FormatConditions.Delete
With Satır
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:=1
.FormatConditions(1).Font.Bold = True
.FormatConditions(1).Interior.ColorIndex = 8
End With
With Sütun
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:=1
.FormatConditions(1).Font.Bold = True
.FormatConditions(1).Interior.ColorIndex = 8
End With
With ActiveCell
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:=1
.FormatConditions(1).Font.Bold = True
.FormatConditions(1).Interior.ColorIndex = 6
End With
2- Satır ve sütun renklendirmeleri aktif hücreye kadar olan aşağıdaki koda nasıl bir ekleme yapılırsa yukarıdaki gibi sayfadaki diğer renkleri silmez.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim oRow As String
Dim oCol As String
Dim DataRg As Range
Dim A As Range
Dim AllRg As Range
Set DataRg = Range("B2:Ah1000")
Set AllRg = Range("A1:Ah1000")
If Target.Cells.Count > 1 Then Exit Sub
If Not Application.Intersect(Target, DataRg) Is Nothing Then
AllRg.Interior.ColorIndex = xlNone
oRow = "A" & Target.Row & ":" & Target.Offset(0, -1).Address
oCol = Target.Offset(1 - Target.Row, 0).Address & ":" & Target.Offset(-1, 0).Address
Range(oRow).Interior.ColorIndex = 10
Range(oCol).Interior.ColorIndex = 17
Else
AllRg.Interior.ColorIndex = xlNone
End If
End Sub
Şimdiden teşekkürler