Birbirini değiştiren hücre

ikikan

Altın Üye
Katılım
3 Mart 2009
Mesajlar
519
Excel Vers. ve Dili
excel 2003 tr
Altın Üyelik Bitiş Tarihi
12.02.2026
Arkadaşlar şöyle bir kod olabilirmi ! A1 hücresi değişince B1 hücresini değiştirecek, B1 hücresi değişince A1 hücresi değişecek?

Örnek vermek gerekirse A1=0 olsun B1= 1000
A1= 100 yapınca B1= 900 olacak
B1=950 yazınca A1= 50 olacak
ayrıca yardımcı bir hücre kullanılmayacak


Sizce mümkün mü?
 

Ömer

Moderatör
Yönetici
Katılım
18 Ağustos 2007
Mesajlar
22,184
Excel Vers. ve Dili
Microsoft 365 Tr
Ofis 2016 Tr
Merhaba,

Çalışma sayfasının kod bölümüne kopyalayın.
Kod:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim deg As Double, s As Byte

    If Intersect(Target, [A1:B1]) Is Nothing Then Exit Sub
    
    deg = 1000
    
    With Target
        If .Count > 1 Then Exit Sub
        s = 1
        If .Column = 2 Then s = 0
        Range("A1").Offset(, s) = deg - .Value
    End With

End Sub
 

YUSUF44

Destek Ekibi
Destek Ekibi
Katılım
4 Ocak 2006
Mesajlar
12,071
Excel Vers. ve Dili
İş : Ofis 365 - Türkçe
Ev: Ofis 365 - Türkçe
Aşağıdaki kodu ilgili sayfanın kod bölümüne (sayfa adına sağ tıklayıp kod görüntüle deyince açılan sayfaya) yapıştırıp deneyiniz:


PHP:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, [A1:B1]) Is Nothing Then Exit Sub
Application.EnableEvents = False
    If Target.Column = 1 Then
        Target.Offset(0, 1) = 1000 - Target
    Else
        Target.Offset(0, -1) = 1000 - Target
    End If
Application.EnableEvents = True
End Sub
 

veyselemre

Özel Üye
Katılım
9 Mart 2005
Mesajlar
3,653
Excel Vers. ve Dili
Pro Plus 2021
Sayfanın kod sayfasına yapıştırın.
Kod:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, [A1:B1]) Is Nothing And IsNumeric(Target) And Target.Count = 1 Then
        Application.EnableEvents = False
        If Target.Address = "$A$1" Then
            [b1] = 1000 - Target
        Else
            [a1] = 1000 - Target
        End If
        Application.EnableEvents = True
    End If
End Sub
 

Seyit Tiken

Uzman
Uzman
Katılım
23 Ağustos 2005
Mesajlar
4,651
Excel Vers. ve Dili
Excel : 2010
Ben olayı böyle anladım.
Kod:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, [a1]) Is Nothing Then
If Target = 100 Then Target.Offset(, 1) = 900
End If
If Not Intersect(Target, [b1]) Is Nothing Then
If Target = 950 Then [a1] = 50
End If
End Sub
 
Üst