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

كيف تظهر العنصر الأول في القائمة المنسدلة بدلاً من أن تكون فارغة؟

القائمة المنسدلة doc الافتراضية لأعلى 1

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

اعرض العنصر الأول في القائمة المنسدلة بدلاً من أن يكون فارغًا باستخدام وظيفة التحقق من صحة البيانات

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


السهم الأزرق الحق فقاعة اعرض العنصر الأول في القائمة المنسدلة بدلاً من أن يكون فارغًا باستخدام وظيفة التحقق من صحة البيانات

في الواقع ، لتحقيق هذه الوظيفة ، تحتاج فقط إلى تطبيق صيغة محددة عند إنشاء قائمة منسدلة ، يرجى القيام بما يلي:

1. حدد الخلايا التي تريد إدراج القائمة المنسدلة فيها ، ثم انقر فوق البيانات > التحقق من صحة البيانات > التحقق من صحة البيانات، انظر لقطة الشاشة:

القائمة المنسدلة doc الافتراضية لأعلى 2

2. في خرجت التحقق من صحة البيانات مربع الحوار ، تحت الإعدادات علامة التبويب، اختر قائمة من السماح ، ثم أدخل هذه الصيغة: = OFFSET (Sheet3! $ A $ 1,0,0،3،1,1، COUNTA (SheetXNUMX! $ A: $ A) -XNUMX،XNUMX) في مصدر مربع النص ، انظر لقطة الشاشة:

ملاحظات: في هذه الصيغة ، Sheet3 هي ورقة العمل التي تحتوي على قائمة البيانات المصدر ، و A1 هي قيمة الخلية الأولى في القائمة.

القائمة المنسدلة doc الافتراضية لأعلى 3

3. ثم اضغط OK ، الآن ، عند النقر فوق خلايا القائمة المنسدلة ، يتم عرض عنصر البيانات الأول دائمًا في الأعلى سواء تم حذف قيم الخلية في نهاية البيانات المصدر ، انظر لقطة الشاشة:

القائمة المنسدلة doc الافتراضية لأعلى 4


السهم الأزرق الحق فقاعة اعرض العنصر الأول تلقائيًا في القائمة المنسدلة بدلاً من أن يكون فارغًا برمز VBA

هنا ، يمكنني أيضًا تقديم رمز VBA الذي يمكن أن يساعدك في إظهار العنصر الأول في القائمة المنسدلة تلقائيًا عند النقر فوق خلايا التحقق من صحة البيانات.

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

رمز فبا: إظهار عنصر البيانات الأول تلقائيًا في القائمة المنسدلة:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Updateby Extendoffice 20160725
    Dim xFormula As String
    On Error GoTo Out:
    xFormula = Target.Cells(1).Validation.Formula1
    If Left(xFormula, 1) = "=" Then
        Target.Cells(1) = Range(Mid(xFormula, 1)).Cells(1).Value
    End If
Out:
End Sub

القائمة المنسدلة doc الافتراضية لأعلى 5

2. ثم احفظ وأغلق نافذة الكود ، والآن ، عند النقر فوق خلية القائمة المنسدلة ، سيتم عرض عنصر البيانات الأول مرة واحدة.

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

🤖 مساعد 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 (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
=OFFSET(Sheet3!$A$1,0,0,COUNTA(Sheet3!$A:$A)+2-1,1) I added +2 to the equation and that worked for me.
This comment was minimized by the moderator on the site
For the VDA code, how can I have only a certain cell range show the first item in the drop down list? Thank you in advance.
This comment was minimized by the moderator on the site
Hi, Akrupa,To solve your problem, maybe the following VBA code can help you:

<div data-tag="code">Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Updateby Extendoffice 20211206
Dim xFormula As String
Dim xRg As Range
Dim xStr As String
Dim xIndex As Integer
xIndex = 2 'Here indicates the cell number of the original data,for example,the original data is A1:A10, to display the A2 cell value, please write 2 here.
On Error GoTo Out:
xFormula = Target.Cells(1).Validation.Formula1
If Left(xFormula, 1) = "=" Then
If Target.Value <> "" Then Exit Sub
xStr = Mid(xFormula, 2)
Set xRg = Application.Range(xStr)
Target.Cells(1) = xRg.Cells(xIndex).Value
End If
Out:
End Sub
Please try, hope it can help you!
This comment was minimized by the moderator on the site
Better but not quite. Using the =OFFSET(Sheet3!$A$1,0,0,COUNTA(Sheet3!$A:$A)-1,1) method eliminates the blanks but still starts you at the bottom of the very long list. I want it to start at the top of the list.
This comment was minimized by the moderator on the site
Once again, you save the day! Thanks!
This comment was minimized by the moderator on the site
Doesn't work for me. I keep getting an error message that says, "There's a problem with this formula. Not trying to type a formula? When the first character is an equal (+) or minus (-) sign, Exel thinks it's a formula.... To get around this, type an apostrophe (') first..."
This comment was minimized by the moderator on the site
Hello!

How can I set a data validation list such that if the drop down value in the cell is deleted, the cell will automatically show a default value (i.e. "-Select-")?

For example, I have a worksheet with multiple drop down lists that I want to show a default value of "-Select-" once the sheet is opened. A user will select values from the lists that will impact the result of calculations throughout the entire spreadsheet. A user may accidentally "delete" the cell contents of the lists. If this happens, rather than the cell becoming blank, I want the cell to show a default value of "-Select-". This scenario occurs in multiple random locations throughout the spreadsheet, not just in one localized place.

I was able to find the following VBA code so far, but it only applies the concept over a range, rather than just individual cells that contain drop down lists. The problem with what I have coded so far is that every single blank cell in the range ends up with "-Select-" in it. Some of the lists are in ranges, but some are also scattered throughout the sheet. The problem I'm having with my current code is that every single blank cell in the range ends up with "-Select-" in it. I'm trying to get this to apply over the entire worksheet to ONLY cells that are drop down lists.

Is what I'm trying to accomplish even possible?

Example file can be found here:
https://drive.google.com/file/d/1VoO8VgFs3IJ0ALwqfk0i8gt69UE4vEKW/view?usp=sharing

Example code:

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim cel As Range
' If Target.Cells.Count > 1 Then Exit Sub 'turning this off allows multiple cells to be selected and deleted at the same time
If Not Intersect(Target, Range("f2:p17")) Is Nothing Then
For Each cel In Range("f2:p17")
Application.EnableEvents = False
If IsEmpty(cel.Value) Then cel.Value = "-Select-"
Next cel
End If
Application.EnableEvents = True
End Sub


Thanks in advance!
This comment was minimized by the moderator on the site
How can I set a data validation list such that if the drop down value in the cell is deleted, the cell will automatically show the a default value (i.e. "-Select-")?

For example, I have a worksheet with multiple drop down lists that I want to show a default value of "-Select-" once the sheet is opened. A user will select values from the lists that will impact the result of calculations throughout the entire spreadsheet. A user may accidentally "delete" the cell contents. If this happens, rather than the cell becoming blank, I want the cell to show a default value of "-Select-". This scenario occurs in multiple random locations throughout the spreadsheet, not just in one localized place.

I was able to come up with the following VBA code so far, but I've only figured out how to apply the concept over a range, rather than just cells that contain a drop down list. The problem with what I have coded so far is that every single blank cell in the range ends up with "-Select-" in it.

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
Dim cel As Range
' If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("f2:p17")) Is Nothing Then
For Each cel In Range("f2:p17")
Application.EnableEvents = False
If IsEmpty(cel.Value) Then cel.Value = "-Select-"
Next cel
End If
Application.EnableEvents = True
End Sub
This comment was minimized by the moderator on the site
select the cell in which you have put the listitem
the range for the listitem is "Opleiding"
in your VBA code:

selection.Value = Range("opleiding").Cells(2, 1)

the result is that the selected item of the listItem is the second item in the range "Opleiding"
This comment was minimized by the moderator on the site
After scroll down select to cells numeric data not come in series only first cell data come select 1,2 different cells and scroll down value not coming 1,2,3,4,5....... only first cell value coming 1,1,1,1,....
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations