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

كيف يتم عرض الرسم البياني دائمًا عند التمرير في Excel؟

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

doc احتفظ بالرسم البياني في العرض 1
السهم لأسفل
doc احتفظ بالرسم البياني في العرض 2

احتفظ دائمًا بالرسم البياني في العرض


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

للاحتفاظ بمخطط في العرض أثناء التمرير على الورقة ، يمكنك تطبيق رمز VBA أدناه لحلها.

1. انقر بزر الماوس الأيمن فوق علامة تبويب الورقة التي تريدها لإبقاء المخطط مرئيًا ، ثم انقر فوق عرض الرمز شكل قائمة السياق. انظر لقطة الشاشة:
doc احتفظ بالرسم البياني في العرض 3

2. في ظهرت ميكروسوفت فيسوال باسيك للتطبيقات نافذة ، الصق الكود أدناه في البرنامج النصي الفارغ.

فبا: احتفظ بالرسم البياني دائمًا في العرض

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'UpdatebyExtendoffice20161111
    Dim CPos As Double
    Application.ScreenUpdating = False
    CPos = ActiveWindow.ScrollRow * ActiveCell.RowHeight
    ActiveSheet.ChartObjects("Chart 2").Activate
    ActiveSheet.Shapes("Chart 2").Top = CPos
    ActiveWindow.Visible = False
    Application.ScreenUpdating = True
End Sub

doc احتفظ بالرسم البياني في العرض 5

3. احفظ وأغلق مربع الحوار ، ثم سيتم نقل المخطط لأسفل أو لأعلى أثناء النقر فوق أي خلية.
doc احتفظ بالرسم البياني في العرض 6

الملاحظات:

(1) في رمز VBA ، الرسم البياني 2 هو اسم المخطط الذي تريد الاحتفاظ به في العرض ، ويمكنك تغييره حسب حاجتك.

(2) لا يمكن لـ VBA هذا دائمًا عرض مجموعة من المخططات.

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

🤖 مساعد 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 (15)
Rated 4.75 out of 5 · 2 ratings
This comment was minimized by the moderator on the site
A mí me pasa que la siguiente vez que abro el archivo, el script ya no funciona. Tengo que copiarlo, borrarlo, cerrar el archivo tras guardarlo, volver a abrir el archivo y volver a pegar el script en VBA. ¿Alguna solución?
Rated 4.5 out of 5
This comment was minimized by the moderator on the site
Hi, save the workbook as excel macro enable workbook, the vba will be work when open next time.https://cdn.extendoffice.com/images/stories/comments/sun-comment/doc-macro-enable.png
This comment was minimized by the moderator on the site
I encountered a problem with unselecting the cell and needed two charts, So I made some changes and it seems to work now.
To use it put the right Chart Name.
*Note: This one is for two charts


Private Sub worksheet_selectionchange(ByVal target As Range)
Dim chartposition As Double

chartposition = ActiveWindow.ScrollRow * ActiveCell.RowHeight
ActiveSheet.Shapes("Chart 2").Top = chartposition

ActiveSheet.ChartObjects("Chart 3").Top = chartposition + 250

End Sub
This comment was minimized by the moderator on the site
Can any one assist. when i follow theses steps


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'UpdatebyExtendoffice20161111
Dim CPos As Double
Application.ScreenUpdating = False
CPos = ActiveWindow.ScrollRow * ActiveCell.RowHeight
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveSheet.Shapes("Chart 2").Top = CPos
ActiveWindow.Visible = False
Application.ScreenUpdating = True
End Sub


i get the following err

Run-Time error '-2147024809 (80070057)':
The item with the specified name was not found

when i debug
ActiveSheet.ChartObjects("Chart 2").Activate
This comment was minimized by the moderator on the site
Hi, Christo, you need to change the chart name "Chart 2" to your chart really name in the script. You can click at the chart and see its name in the name box. See screenshot:
https://www.extendoffice.com/images/stories/comments/sun-comment/do_chart_name.png
This comment was minimized by the moderator on the site
yes thanks. after a made the question i realised my chart name was wrong
thanks

ps.
do you perhaps know how i can make the chart kept in view as i scroll without clicking where it must follow
This comment was minimized by the moderator on the site
can I use Kutools to automatically use that VBA for my charts??
This comment was minimized by the moderator on the site
Sorry, Wangnuli, Kutools has not support this so far.
This comment was minimized by the moderator on the site
Hola muchas gracias por el código, utilizando este código ¿Hay alguna manera de limitar qué tan alto en la hoja se reubicará el gráfico? por ejemplo, no quiero que se coloque encima de la fila 9. Ayuda por favor.
Rated 5 out of 5
This comment was minimized by the moderator on the site
Is there a way to limit how high up on the sheet the chart will relocate to? I don't want it to affix above row 8
This comment was minimized by the moderator on the site
Is there a similar formula that can be built for Google Sheets?
This comment was minimized by the moderator on the site
This macro did exactly what I wanted. However it created another problem that I wondered if you might have a solution to.

While this macro is active I cannot select cells for other purposes such as formatting or merging them. Click and drag, shift nor ctrl work to select a group of cells. I can only select the one cell I clicked on. I frequently want to change formatting (background, fill down a formula, etc.) The only way I have been able to do this is to delete the macro, save, make my formatting changes, paste the macro back in and save.

Is there a simpler way to do this? Perhaps:

1. (preferred) A simple keystroke that would temporarily disable the macro and then re-enable it.

2. Some code added to the macro to allow selection of a group of cells.

Dennis
This comment was minimized by the moderator on the site
This was good but I wish there was a way that it would just move with the scroll wheel, like heading lines. Also if I want to select a cell it takes two clicks. The first click moves the chart but also selects the chart so I have to click again to select the cell.
This comment was minimized by the moderator on the site
I added "activecell.select" on the last line of this code and it fixed the double clicking issue. It will automatically select the last active cell, which will be the one you clicked on to move the chart. Hope this helps.
This comment was minimized by the moderator on the site
THIS IS WHAT I NEEDED! GOLDEN!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations