Aynı fonksiyon altında 3 işlem

Katılım
25 Aralık 2008
Mesajlar
21
Excel Vers. ve Dili
2007
Merhaba, aşağıda yer alan kodları bu şekilde kullandığımda hata veriyor, 3ünü birleştirmem gerekiyor sanırım. Bu üç kodu aynı anda nasıl kullanabilirim acaba.


Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim RaBereich As Range
Set RaBereich = Range("B5:b20000")
If Not Intersect(Range(Target.Address), RaBereich) Is Nothing Then UserForm1.Show
Set RaBereich = Nothing
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim RaBereich2 As Range
Set RaBereich2 = Range("c5:c20000")
If Not Intersect(Range(Target.Address), RaBereich2) Is Nothing Then UserForm2.Show
Set RaBereich2 = Nothing
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim RaBereich3 As Range
Set RaBereich3 = Range("H5:H20000")
If Not Intersect(Range(Target.Address), RaBereich3) Is Nothing Then UserForm3.Show
Set RaBereich3 = Nothing
End Sub
 

ÖmerFaruk

Destek Ekibi
Destek Ekibi
Katılım
22 Ekim 2017
Mesajlar
4,779
Excel Vers. ve Dili
Microsoft 365 Tr-64
C++:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim RaBereich As Range
Dim RaBereich2 As Range
Dim RaBereich3 As Range

Set RaBereich = Range("B5:b20000")
Set RaBereich2 = Range("c5:c20000")
Set RaBereich3 = Range("H5:H20000")
    
If Not Intersect(Range(Target.Address), RaBereich) Is Nothing Then UserForm1.Show
If Not Intersect(Range(Target.Address), RaBereich2) Is Nothing Then UserForm2.Show
If Not Intersect(Range(Target.Address), RaBereich3) Is Nothing Then UserForm3.Show

Set RaBereich = Nothing
Set RaBereich2 = Nothing
Set RaBereich3 = Nothing
End Sub
 
Katılım
25 Aralık 2008
Mesajlar
21
Excel Vers. ve Dili
2007
C++:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim RaBereich As Range
Dim RaBereich2 As Range
Dim RaBereich3 As Range

Set RaBereich = Range("B5:b20000")
Set RaBereich2 = Range("c5:c20000")
Set RaBereich3 = Range("H5:H20000")
   
If Not Intersect(Range(Target.Address), RaBereich) Is Nothing Then UserForm1.Show
If Not Intersect(Range(Target.Address), RaBereich2) Is Nothing Then UserForm2.Show
If Not Intersect(Range(Target.Address), RaBereich3) Is Nothing Then UserForm3.Show

Set RaBereich = Nothing
Set RaBereich2 = Nothing
Set RaBereich3 = Nothing
End Sub
Teşekkür ederim.
 

Korhan Ayhan

Administrator
Yönetici
Admin
Katılım
15 Mart 2005
Mesajlar
42,333
Excel Vers. ve Dili
Microsoft 365 Tr-En 64 Bit
Alternatif;

Aşağıdaki gibi de kullanabilirsiniz.

C++:
Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    If Not Intersect(Target, Range("B5:B20000")) Is Nothing Then UserForm1.Show
    If Not Intersect(Target, Range("C5:C20000")) Is Nothing Then UserForm2.Show
    If Not Intersect(Target, Range("H5:H20000")) Is Nothing Then UserForm3.Show
End Sub
 
Üst