Ana içeriğe atla

Excel'de birden çok çalışma sayfasındaki açılır listeler nasıl senkronize edilir?

Tam olarak aynı açılır öğeleri içeren bir çalışma kitabındaki birkaç çalışma sayfasında açılan listeleriniz olduğunu varsayalım. Şimdi, bir çalışma sayfasındaki açılır listeden bir öğe seçtiğinizde, diğer çalışma sayfalarındaki açılır listeler aynı seçimle otomatik olarak eşitlenecek şekilde, çalışma sayfaları arasında açılır listeleri senkronize etmek istiyorsunuz. Bu makale, bu sorunu çözmenize yardımcı olacak bir VBA kodu sağlar.

Birden çok çalışma sayfasındaki açılır listeleri VBA koduyla senkronize edin


Birden çok çalışma sayfasındaki açılır listeleri VBA koduyla senkronize edin

Örneğin, açılır listeler şu adlarla adlandırılan beş çalışma sayfasındadır: Sayfa1, Sayfa2, ..., Sayfa5, Sayfa1'deki açılır seçime göre diğer çalışma sayfalarındaki açılır listeleri senkronize etmek için lütfen aşağıdaki VBA kodunu uygulayarak bunu yapın.

1. Sayfa1'i açın, sayfa sekmesine sağ tıklayın ve Kodu Görüntüle sağ tıklama menüsünden.

2. içinde Uygulamalar için Microsoft Visual Basic penceresinde aşağıdaki VBA kodunu yapıştırın. Sayfa1 (Kod) pencere.

VBA kodu: Birden çok çalışma sayfasındaki açılır listeyi senkronize edin

Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 20220815
    Dim tSheet1 As Worksheet
    Dim tRange As Range
    Dim xRangeStr As String
    On Error Resume Next
    If Target.Count > 1 Then Exit Sub
    
    xRangeStr = "A2:A11"

    Set tRange = Intersect(Target, Range(xRangeStr))
    If Not tRange Is Nothing Then
        xRangeStr = tRange.Address
        Application.EnableEvents = False
        Set tSheet1 = ActiveWorkbook.Worksheets("Sheet2")
        tSheet1.Range(xRangeStr).Value = Target.Value
        Set tSheet1 = ActiveWorkbook.Worksheets("Sheet3")
        tSheet1.Range(xRangeStr).Value = Target.Value
        Set tSheet1 = ActiveWorkbook.Worksheets("Sheet4")
        tSheet1.Range(xRangeStr).Value = Target.Value
        Set tSheet1 = ActiveWorkbook.Worksheets("Sheet5")
        tSheet1.Range(xRangeStr).Value = Target.Value
        Application.EnableEvents = True
    End If
    
End Sub

Notlar:

1) Kodda, A2: A11 açılır listeyi içeren aralıktır. Tüm açılır listelerin farklı çalışma sayfalarında aynı aralıkta olduğundan emin olun.
2) Sayfa2, Sayfa3, Sayfa4 ve Sheet5 Sayfa1'deki açılır listeye göre senkronize etmek istediğiniz açılır listeleri içeren çalışma sayfalarıdır;
3) Kodda daha fazla çalışma sayfası eklemek için lütfen aşağıdaki iki satırı “ satırından önce ekleyin.Application.EnableEvents = True”, ardından sayfa adını değiştirin”Sheet5"İhtiyacınız olan isme.
tSheet1 = ActiveWorkbook.Worksheets("Sayfa5") olarak ayarlayın
tSheet1.Range(xRangeStr).Value = Target.Value

3. Tuşuna basın. Ara Toplam + Q kapatmak için anahtarlar Uygulamalar için Microsoft Visual Basic pencere.

Şu andan itibaren, içindeki açılır listeden bir öğe seçtiğinizde Sayfa1, belirtilen çalışma sayfalarındaki açılır listeler, aynı seçime sahip olacak şekilde otomatik olarak senkronize edilecektir. Aşağıdaki demoya bakın.


Demo: Excel'de Birden Çok Çalışma Sayfasındaki Açılır Listeleri Senkronize Etme

En İyi Ofis Üretkenlik Araçları

🤖 Kutools AI Yardımcısı: Aşağıdakilere dayalı olarak veri analizinde devrim yaratın: Akıllı Yürütme   |  Kodunu oluşturun  |  Özel Formüller Oluşturun  |  Verileri Analiz Edin ve Grafikler Oluşturun  |  Kutools İşlevlerini Çağır...
Popüler Özellikler: Yinelenenleri Bul, Vurgula veya Tanımla   |  Boş Satırları Sil   |  Veri Kaybı Olmadan Sütunları veya Hücreleri Birleştirin   |   Formülsüz Tur ...
Süper Arama: Çoklu Ölçütlü VLookup    Çoklu Değer VLookup  |   Birden Çok Sayfada VLookup   |   Bulanık Arama ....
Gelişmiş Açılır Liste: Hızla Açılır Liste Oluşturun   |  Bağımlı Açılır Liste   |  Çoklu Seçim Açılır Liste ....
Sütun Yöneticisi: Belirli Sayıda Sütun Ekleme  |  Sütunları Taşı  |  Gizli Sütunların Görünürlük Durumunu Değiştir  |  Aralıkları ve Sütunları Karşılaştırın ...
Öne Çıkan Özellikler: Izgara Odağı   |  Tasarım görünümü   |   Büyük Formül Çubuğu    Çalışma Kitabı ve Sayfa Yöneticisi   |  Kaynak Kütüphanesi (Otomatik metin)   |  Tarih Seçici   |  Çalışma Sayfalarını Birleştirin   |  Hücreleri Şifrele/Şifresini Çöz    E-postaları Listeye Göre Gönder   |  Süper Filtre   |   Özel Filtre (kalın/italik/üstü çizili filtre...) ...
En İyi 15 Araç Seti12 Metin Tools (Metin ekle, Karakterleri Kaldır, ...)   |   50+ Grafik Türleri (Gantt şeması, ...)   |   40+ Pratik Formüller (Yaşı doğum gününe göre hesapla, ...)   |   19 sokma Tools (QR Kodunu Girin, Yoldan Resim Ekle, ...)   |   12 Dönüştürme Tools (Sayılardan Kelimelere, Para Birimi Dönüştürme, ...)   |   7 Birleştir ve Böl Tools (Gelişmiş Kombine Satırları, Bölünmüş hücreler, ...)   |   ... ve dahası

Kutools for Excel ile Excel Becerilerinizi Güçlendirin ve Daha Önce Hiç Olmadığı Gibi Verimliliği Deneyimleyin. Kutools for Excel, Üretkenliği Artırmak ve Zamandan Tasarruf Etmek için 300'den Fazla Gelişmiş Özellik Sunar.  En Çok İhtiyacınız Olan Özelliği Almak İçin Buraya Tıklayın...

Açıklama


Office Tab, Office'e Sekmeli Arayüz Getirir ve İşinizi Çok Daha Kolay Hale Getirir

  • Word, Excel, PowerPoint'te sekmeli düzenlemeyi ve okumayı etkinleştirin, Publisher, Access, Visio ve Project.
  • Yeni pencereler yerine aynı pencerenin yeni sekmelerinde birden çok belge açın ve oluşturun.
  • Üretkenliğinizi% 50 artırır ve her gün sizin için yüzlerce fare tıklamasını azaltır!
Comments (7)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi,

thanks for the code, it worked well. Is it possible to adapt the code so that i restructure all sheets as main sheet and can change all other drop down menus from sheet 1 and at the same time from sheet 2, sheet 3, ...? I don't know anything about VBA, but I could use your code successfully for sheet1 as main sheet. Now need the possibility to synchronize the drop down menus across all sheets.

Thanks!
This comment was minimized by the moderator on the site
Hi,

I appreciate your content a lot. I am struggling to find the code to write to have drop-downs synchronized in excel. My synchronization needs to be a lot more complex and I have been trying to use ChatGPT to help write it but a robot can only do so much. I figured I would reach out and see if you could provide some direction or advise if I am making progress since I am becoming more and more frustrated. I need drop downs in Sheet 3 to correspond with drop-downs on Sheet 1 and Sheet 2. The drop-downs in Sheet 3 are all in Column A and each cell in Column A corresponds to a different dropdown on either Sheet 1 or Sheet 2. Those dropdowns have conditional formatting to highlight certain cells when an item is selected from the list. The options are "Complete" (Highlights Green), "Not Satisfied" (Highlights Orange), and "Delinquent" (Highlights red). It is probably confusing to read but I use excel to track loan payments and I have very detailed instructions I am trying to code in excel. For example, I am trying to write the code to tell excel to do the following:

1. I need cell A7 on ACORE Cash Mgmt Sheet (Sheet 3) to align with the dropdown and the conditional formatting in cell C427 on the 8th payment sheet (Sheet 1)
2. I need A8 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C231 on the 8th payment sheet
3. I need A9 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C133 on the 8th payment sheet
4. I need A10 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C270 on the 8th payment sheet
5. I need A11 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C351 on the 8th payment sheet
6. I need A12 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C3 on the 8th payment sheet
7. I need A13 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C39 on the 8th payment sheet
8. I need A14 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C116 on the 8th payment sheet
9. I need A15 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C144 on the 8th payment sheet
10. I need A16 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C64 on the 8th payment sheet
11. I need A17 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C158 on the 8th payment sheet
12. I need A18 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C199 on the 8th payment sheet
13. I need A19 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C103 on the 8th payment sheet
14. I need A20 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C380 on the 8th payment sheet
15. I need A21 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C81 on the 8th payment sheet
16. I need A22 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C169 on the 8th payment sheet
17. I need A23 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C418 on the 8th payment sheet
18. I need A24 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C301 on the 8th payment sheet
19. I need A25 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C95 on the 8th payment sheet
20. I need A26 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C407 on the 8th payment sheet
21. I need A27 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C15 on the 8th payment sheet
22. I need A28 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C340 on the 8th payment sheet
23. I need A29 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C211 on the 8th payment sheet
24. I need A30 on ACORE Cash Mgmt Sheet to align with the dropdown and the conditional formatting in C52 on the 8th payment sheet


This is the code that got me the closet to do what I wanted...however, I could not get it to work exactly how I wanted and it would only be for the first instructions and not include everything else:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim SourceSheet As Worksheet
Dim DestSheet As Worksheet
Dim SourceCell As Range
Dim DestCell As Range
Dim FormattingRange As Range

' Set the source and destination sheets
Set SourceSheet = ThisWorkbook.Sheets("ACORE Cash Mgmt")
Set DestSheet = ThisWorkbook.Sheets("8th Payment")

' Set the source and destination cells
Set SourceCell = SourceSheet.Range("A7")
Set DestCell = DestSheet.Range("C427")

' Set the formatting range
Set FormattingRange = DestCell

' Check if the change was in the source cell
If Not Intersect(Target, SourceCell) Is Nothing Then
' Copy the value from the source cell to the destination cell
DestCell.Value = SourceCell.Value

' Apply conditional formatting based on the value
Select Case SourceCell.Value
Case "Complete"
FormattingRange.Interior.Color = RGB(146, 208, 80) ' Green
Case "Not Satisfied"
FormattingRange.Interior.Color = RGB(255, 192, 0) ' Orange
Case "Delinquent"
FormattingRange.Interior.Color = RGB(255, 0, 0) ' Red
Case Else
FormattingRange.Interior.ColorIndex = xlNone ' Clear formatting
End Select
End If
End Sub


Are you able to provide any expertise? I hope this all makes some sense considering it reads quite poorly.

Thank you in advance,

Sam
This comment was minimized by the moderator on the site
Crystal,

Thank you so much for your response, this worked! How could I modify the code to add another cell in the same sheet 6, B3 that also needed to be synchronized with B8 in sheet 7? I have attempted to modify it below, however it ends up putting the contents of B3 on sheet 6 in B7 on sheet 7 instead of B8.


Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 20221025
Dim tSheet1 As Worksheet
Dim tRange1 As Range
Dim tRange2 As Range
Dim xRangeStr1 As String
Dim xRangeStr2 As String
On Error Resume Next
If Target.Count > 1 Then Exit Sub

xRangeStr1 = "B2"
xRangeStr2 = "B3"

Set tRange1 = Range("B7")
If Not tRange1 Is Nothing Then
xRangeStr1 = tRange1.Address
Application.EnableEvents = False
Set tSheet1 = ActiveWorkbook.Worksheets("Sheet7")
tSheet1.Range(xRangeStr1).Value = Target.Value
Application.EnableEvents = True
End If

Set tRange2 = Range("B8")
If Not tRange2 Is Nothing Then
xRangeStr2 = tRange2.Address
Application.EnableEvents = False
Set tSheet1 = ActiveWorkbook.Worksheets("Sheet7")
tSheet1.Range(xRangeStr2).Value = Target.Value
Application.EnableEvents = True
End If

End Sub
This comment was minimized by the moderator on the site
Hi,

How can I do this if my dropdowns are in different ranges? To elaborate, I have one drop down in sheet 7 that is in cell B7 and the same dropdown on sheet 6 in cell B2.

Thank you,
Elaine
This comment was minimized by the moderator on the site
Hi E,
The following VBA code can help.
Here I take Sheet6 as the main worksheet, right click the sheet tab, select View Code from the right-click menu, then copy the following code in the Sheet6 (Code) window. When you select any item from the drop-down list in B2 of Sheet6, the drop-down list in B7 of Sheet7 will be cynchronized to have the same selected item.

Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 20221025
    Dim tSheet1 As Worksheet
    Dim tRange As Range
    Dim xRangeStr As String
    On Error Resume Next
    If Target.Count > 1 Then Exit Sub
    
    xRangeStr = "B2"
    
    Set tRange = Range("B7")
    If Not tRange Is Nothing Then
        xRangeStr = tRange.Address
        Application.EnableEvents = False
        Set tSheet1 = ActiveWorkbook.Worksheets("Sheet7")
        tSheet1.Range(xRangeStr).Value = Target.Value
        Application.EnableEvents = True
    End If
    
End Sub
This comment was minimized by the moderator on the site
Hi Crystal,

Thank you so much for your response, your code worked! I have a cell right under b2 and b7, b3 and b8 respectively that need to have the same function. I tried to rewrite your code as shown below, however this did not work. It caused b7 instead of b8 to change when I changed b3. Might you be able to identify what I am doing wrong?

Thank you so much!

Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 20221025
    Dim tSheet1 As Worksheet
    Dim tRange1 As Range
    Dime tRange2 As Range
    Dim xRangeStr1 As String
    Dim xRangeStr2 As String
    On Error Resume Next
    If Target.Count > 1 Then Exit Sub
    
    xRangeStr1 = "B2"
    xRangeStr2="B3"
    
    Set tRange1 = Range("B7")
    If Not tRange1 Is Nothing Then
        xRangeStr1 = tRange1.Address
        Application.EnableEvents = False
        Set tSheet1 = ActiveWorkbook.Worksheets("Sheet7")
        tSheet1.Range(xRangeStr1).Value = Target.Value
        Application.EnableEvents = True
    End If
    
    Set tRange2 = Range("B8")
    If Not tRange2 Is Nothing Then
        xRangeStr2 = tRange2.Address
        Application.EnableEvents = False
        Set tSheet1 = ActiveWorkbook.Worksheets("Sheet7")
        tSheet1.Range(xRangeStr2).Value = Target.Value
        Application.EnableEvents = True
    End If

End Sub
This comment was minimized by the moderator on the site
Hi E,
There is something wrong with the VBA code I replied to you above.
For the new question you mentioned, please try the following code.

Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 20221031
    
    Dim xBool1 As Boolean
    Dim xBool2 As Boolean
    Dim xRgStr As String
    Dim tRange As Range
    
    xRangeStr1 = "B2"
    xRangeStr2 = "B3"
    xRgStr = ""
    
    On Error Resume Next
    If Target.Count > 1 Then Exit Sub
    xBool1 = Intersect(Target, Range(xRangeStr1)) Is Nothing
    xBool2 = Intersect(Target, Range(xRangeStr2)) Is Nothing
    
    If xBool1 And xBool2 Then Exit Sub
    
    xRgStr = Target.Address(False, False, xlA1, False, False)
    
    If Target.Address(False, False, xlA1, False, False) = xRangeStr1 Then
        xRgStr = "b7"
    ElseIf Target.Address(False, False, xlA1, False, False) = xRangeStr2 Then
        xRgStr = "b8"
    End If
    If xRgStr = "" Then Exit Sub
    
    Application.EnableEvents = False
    Set tSheet1 = ActiveWorkbook.Worksheets("Sheet7")
    tSheet1.Range(xRgStr).Value = Target.Value
    Application.EnableEvents = True

End Sub
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations