انتقل إلى المحتوى الرئيسي

كيفية مزامنة القوائم المنسدلة في أوراق عمل متعددة في إكسيل؟

افترض أن لديك قوائم منسدلة في عدة أوراق عمل في مصنف تحتوي على نفس العناصر المنسدلة بالضبط. الآن تريد مزامنة القوائم المنسدلة عبر أوراق العمل بحيث بمجرد تحديد عنصر من القائمة المنسدلة في ورقة عمل واحدة ، تتم مزامنة القوائم المنسدلة في أوراق العمل الأخرى تلقائيًا مع نفس التحديد. توفر هذه المقالة رمز VBA لمساعدتك في حل هذه المشكلة.

مزامنة القوائم المنسدلة في أوراق عمل متعددة باستخدام كود VBA


مزامنة القوائم المنسدلة في أوراق عمل متعددة باستخدام كود VBA

على سبيل المثال ، القوائم المنسدلة موجودة في خمس أوراق عمل مسماة ورقة 1 ، ورقة 2 ، ...، ورقة 5 ، لمزامنة القوائم المنسدلة في أوراق العمل الأخرى وفقًا للاختيار المنسدل في الورقة 1 ، يرجى تطبيق رمز VBA التالي لإنجازه.

1. افتح الورقة 1 ، وانقر بزر الماوس الأيمن فوق علامة تبويب الورقة وحدد عرض الرمز من قائمة النقر بزر الماوس الأيمن.

2. في ال ميكروسوفت فيسوال باسيك للتطبيقات في النافذة ، قم بلصق رمز VBA التالي في ملف الورقة 1 (الرمز) نافذة.

كود فبا: مزامنة القائمة المنسدلة في أوراق عمل متعددة

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

الملاحظات:

1) في الكود ، A2: A11 هو النطاق الذي يحتوي على القائمة المنسدلة. تأكد من أن جميع القوائم المنسدلة موجودة في نفس النطاق عبر أوراق عمل مختلفة.
2) ورقة 2 ، ورقة 3 ، ورقة 4 و Sheet5 هي أوراق عمل تحتوي على قوائم منسدلة تريد مزامنتها استنادًا إلى القائمة المنسدلة في الورقة 1 ؛
3) لإضافة المزيد من أوراق العمل في الكود ، يرجى إضافة السطرين التاليين قبل السطر "Application.EnableEvents = صحيح"، ثم قم بتغيير اسم الورقة"Sheet5"إلى الاسم الذي تحتاجه.
اضبط tSheet1 = ActiveWorkbook.Worksheets ("Sheet5")
tSheet1.Range (xRangeStr) .Value = Target.Value

3. اضغط على قديم + Q مفاتيح لإغلاق ميكروسوفت فيسوال باسيك للتطبيقات نافذة.

من الآن فصاعدًا ، عند تحديد عنصر من القائمة المنسدلة في ورقة 1 ، ستتم مزامنة القوائم المنسدلة في أوراق العمل المحددة تلقائيًا للحصول على نفس التحديد. انظر أدناه التجريبي.


عرض توضيحي: مزامنة القوائم المنسدلة في أوراق عمل متعددة في Excel

أفضل أدوات إنتاجية المكتب

🤖 مساعد Kutools AI: إحداث ثورة في تحليل البيانات على أساس: التنفيذ الذكي   |  إنشاء التعليمات البرمجية  |  إنشاء صيغ مخصصة  |  تحليل البيانات وإنشاء الرسوم البيانية  |  استدعاء وظائف Kutools...
الميزات الشعبية: البحث عن التكرارات أو تمييزها أو تحديدها   |  حذف الصفوف الفارغة   |  دمج الأعمدة أو الخلايا دون فقدان البيانات   |   جولة بدون صيغة 
سوبر بحث: معايير متعددة VLookup    VLookup ذات القيمة المتعددة  |   VLookup عبر أوراق متعددة   |   بحث غامض ....
قائمة منسدلة متقدمة: إنشاء القائمة المنسدلة بسرعة   |  القائمة المنسدلة التابعة   |  قائمة منسدلة متعددة التحديد ....
مدير العمود: إضافة عدد محدد من الأعمدة  |  نقل الأعمدة  |  تبديل حالة رؤية الأعمدة المخفية  |  مقارنة النطاقات والأعمدة 
الميزات المميزة: التركيز على الشبكة   |  عرض تصميم   |   شريط الفورمولا الكبير    مدير المصنفات والأوراق   |  مكتبة الموارد (النص السيارات)   |  منتقي التاريخ   |  اجمع أوراق العمل   |  تشفير/فك تشفير الخلايا    إرسال رسائل البريد الإلكتروني عن طريق القائمة   |  سوبر تصفية   |   مرشح خاص (تصفية غامق / مائل / يتوسطه خط ...) ...
أفضل 15 مجموعة أدوات12 نص الأدوات (إضافة نص, إزالة الأحرف، ...)   |   +50 رسم الأنواع (مخطط جانت، ...)   |   40+ عملي الصيغ (احسب العمر على أساس تاريخ الميلاد، ...)   |   19 إدخال الأدوات (أدخل رمز الاستجابة السريعة, إدراج صورة من المسار، ...)   |   12 تحويل الأدوات (أرقام إلى كلمات, نتيجة تحويل عملة، ...)   |   7 دمج وتقسيم الأدوات (الجمع بين الصفوف المتقدمة, تقسيم الخلايا، ...)   |   ... و اكثر

عزز مهاراتك في Excel باستخدام Kutools for Excel، واختبر كفاءة لم يسبق لها مثيل. يقدم Kutools for Excel أكثر من 300 ميزة متقدمة لتعزيز الإنتاجية وتوفير الوقت.  انقر هنا للحصول على الميزة التي تحتاجها أكثر...

الوصف


يجلب Office Tab الواجهة المبوبة إلى Office ، ويجعل عملك أسهل بكثير

  • تمكين التحرير والقراءة المبوبة في Word و Excel و PowerPointوالناشر والوصول و Visio والمشروع.
  • فتح وإنشاء مستندات متعددة في علامات تبويب جديدة من نفس النافذة ، بدلاً من النوافذ الجديدة.
  • يزيد من إنتاجيتك بنسبة 50٪ ، ويقلل مئات النقرات بالماوس كل يوم!
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