• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

İki makro kodun birleştirilmesi

  • Konbuyu başlatan Konbuyu başlatan klop01
  • Başlangıç tarihi Başlangıç tarihi

klop01

Altın Üye
Katılım
19 Aralık 2016
Mesajlar
663
Excel Vers. ve Dili
2021 Türkçe 64 Bit
Hazır ve düzgün çalışan iki makro kodu var.
Birisi aktif hücre, satır ve sütun renklendiriyor.
İkincisi tıklanan hücredeki yazıyı büyütüyor.
BU İKİ KOD BİRLEŞTİRİLİP AYNI ALANDA İŞLER HALE GETİRİLEBİLİR Mİ?

Aktif hücre, satır ve sütun renklendirme kodu:
Kod:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("B3:AO64")) Is Nothing Then
    Cells.FormatConditions.Delete
    Exit Sub
End If

Dim Satır As Range, Sütun As Range
    
    Set Satır = Range(Cells(ActiveCell.Row, 2), Cells(ActiveCell.Row, 41))
    Set Sütun = Range(Cells(Target.Row, ActiveCell.Column), Cells(3, 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
End Sub


Tıklanan hücredeki yazıyı büyüten kod:
Kod:
Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo Son
With [B3:AO64]
    Cells.Font.Size = 10
    Cells.Font.Italic = False
End With
If Intersect(Target, [B3:AO64]) Is Nothing Then Exit Sub
Application.ScreenUpdating = False
If Not IsEmpty(Target) Then
Target.Font.Size = 20
Target.Font.Italic = True
End If
Son:
Application.ScreenUpdating = True
End Sub
 
Kod:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("B3:AO64")) Is Nothing Then
    Cells.FormatConditions.Delete
    Exit Sub
End If

Dim Satır As Range, Sütun As Range
    
    Set Satır = Range(Cells(ActiveCell.Row, 2), Cells(ActiveCell.Row, 41))
    Set Sütun = Range(Cells(Target.Row, ActiveCell.Column), Cells(3, 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
    
On Error GoTo Son
With [B3:AO64]
    Cells.Font.Size = 10
    Cells.Font.Italic = False
End With

If Intersect(Target, [B3:AO64]) Is Nothing Then Exit Sub
Application.ScreenUpdating = False
If Not IsEmpty(Target) Then
Target.Font.Size = 20
Target.Font.Italic = True
End If
Son:
Application.ScreenUpdating = True
End Sub
 
Sayın Mahmut Bayram,
Teşekkür ederim, kod sorunsuz çalışıyor.
 
Geri
Üst