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

كيفية تشغيل الماكرو نفسه على أوراق عمل متعددة في نفس الوقت في Excel؟

عادة ، يمكننا تشغيل ماكرو في ورقة العمل ، إذا كانت هناك أوراق متعددة تحتاج إلى تطبيق هذا الماكرو نفسه ، فيجب عليك تشغيل الكود واحدًا تلو الآخر. إذا كان هناك أي طريقة سريعة أخرى لتشغيل نفس الماكرو على أوراق عمل متعددة في وقت واحد في Excel؟

قم بتشغيل أو تنفيذ نفس الماكرو في أوراق عمل متعددة في نفس الوقت باستخدام تعليمات VBA البرمجية


قم بتشغيل أو تنفيذ نفس الماكرو في أوراق عمل متعددة في نفس الوقت باستخدام تعليمات VBA البرمجية

لتشغيل ماكرو على أوراق متعددة في نفس الوقت دون تشغيله واحدًا تلو الآخر ، يمكنك تطبيق كود فبا التالي ، يرجى القيام بذلك على النحو التالي:

1. اضغط باستمرار على ALT + F11 مفاتيح لفتح ميكروسوفت فيسوال باسيك للتطبيقات نافذة.

2. انقر إدراج > وحدة، ولصق الماكرو التالي في ملف وحدة نافذة او شباك.

كود فبا: قم بتشغيل الماكرو نفسه على أوراق عمل متعددة في نفس الوقت:

Sub Dosomething()
    Dim xSh As Worksheet
    Application.ScreenUpdating = False
    For Each xSh In Worksheets
        xSh.Select
        Call RunCode
    Next
    Application.ScreenUpdating = True
End Sub
Sub RunCode()
    'your code here
End Sub

ملاحظات: في الكود أعلاه ، يرجى نسخ ولصق الكود الخاص بك بدون ملف فرعية العنوان و نهاية الفرعية تذييل بين رونكود فرعي () و نهاية الفرعية نصوص. انظر لقطة الشاشة:

doc قم بتشغيل الماكرو في جميع الأوراق 1

3. ثم ضع المؤشر على ماكرو الجزء الأول ، واضغط على F5 مفتاح لتشغيل الكود ، وسيتم تطبيق كود الماكرو الخاص بك على ورقة واحدة.


إزالة كافة وحدات الماكرو من مصنفات متعددة:

كوتولس ل إكسيل's دفعة إزالة كافة وحدات الماكرو يمكن أن تساعدك الأداة المساعدة على إزالة كافة وحدات الماكرو من مصنفات متعددة حسب حاجتك. قم بتنزيل Kutools for Excel والإصدار التجريبي المجاني الآن!

doc قم بتشغيل الماكرو إذا تغيرت الخلية 3

كوتولس ل إكسيل: مع أكثر من 300 وظيفة إضافية مفيدة في Excel ، يمكنك تجربتها مجانًا دون قيود خلال 30 يومًا. تنزيل وتجربة مجانية الآن!

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

🤖 مساعد 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 (16)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
The original macro "How to run the same macro on multiple worksheets at same time in Excel" is fantastic for my purposes, thanks so much. I was wondering if there's a way to get it to return to the first worksheet where I have a control to run the macro. Currently it goes through 25 worksheets doing my code (autofit & Sort by date) and stops once it's done the last worksheet of the 25. Returning to the first sheet would be the icing on the cake! Thanks in advance for thinking about this.
This comment was minimized by the moderator on the site
is there a way to only do it on selected worksheets and not all?
This comment was minimized by the moderator on the site
Hello, karen,
To run the code on selected sheet, please apply the below code:
Step1: Copy anf paste the below code into the Module Window
'Replace this code with your own, but keep the script inside the parentheses
Sub LCase(ws As Worksheet)
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
    Rng.Value = VBA.LCase(Rng.Value)
Next
End Sub

Sub RunOnSelectedSheets()
    Dim ws As Worksheet
    For Each ws In ActiveWindow.SelectedSheets
        LCase ws    'change the LCase code name to your own code name
    Next ws
End Sub



Step2: Replace the first section of code above with your own code, but keep the script inside the parentheses. And change the LCase code name to your own code name.

Step3: Then, select the worksheet you want to run this code.
After running the code, your code will be executed on each of the selected sheets.

Please have a try, hope it can help you!
This comment was minimized by the moderator on the site
Terimakasih sebelumnya atas ilmu ilmu yg sudah di share. Saya sudah memakai beberapa VBA anda.

Tapi bolehkan saya meminta tolong untul mencarikan VBA yg tepat untuk mengaktifkan VBA yg sudah ada di sheet tertentu tanpa harus masuk ke sheet tersebut.

Contohnya.
Saya sudah menggunakan vBA anda yg berfungsi untuk mengurutkan data secara otomatis.

Tetapi ketika data yg saya terapkan itu berubah karena hasil pencarian data dari sheet yg berbeda. vBA tersebut tidak aktif. Harus terlebih dahulu masuk ke Sheet Tersebut untuk merubah data dengan manual barulah VBa pengurutan dat tersebut aktif.

Bisakah dicarikan VBA nya?
This comment was minimized by the moderator on the site
It works, but the current sheet is always running twice. The rest sheets are perfect and run only once!
This comment was minimized by the moderator on the site
Hello, hou,
May be you can use the below code to your need:
Sub WorksheetLoop()
         Dim Current As Worksheet
         For Each Current In Worksheets

          'Insert your code here.
           
      End Sub


Note: In the above code, please copy and paste your own code without the Sub heading and End Sub footer.

Please try, hope it can help you!
This comment was minimized by the moderator on the site
Thank you so much! But it's not working. It only runs the current sheet for several times.
This comment was minimized by the moderator on the site
How do you exclude certain sheets and add On Error Resume Next? Thanks in advance
This comment was minimized by the moderator on the site
Before xSh.selectyou have to activate
So,xSh.activatexSh.select
This comment was minimized by the moderator on the site
The code "Run the same macro on multiple worksheets at same time" works perfectly, Thanks !

However I have this error at "xSh.Select" and I don't know why...there is no issue visible in the sheets... AND I don't have any hidden sheets.

The error is '1004': Method'Select' of object '_Worksheet' failed


Thanks in advance for your help
This comment was minimized by the moderator on the site
For those wiFor those with 1004 runtime error, verify you don´t have any hidden sheets. If you do, unhide them. Then this code snippet works. Greetings.th 1004 runtime error, verify you don´t have any hidden sheets. If you do, unhide them. Then this code snippet works. Greetings.
This comment was minimized by the moderator on the site
Is there a way to make this run only on unhidden sheets? I need this code to run only on visible sheets.
This comment was minimized by the moderator on the site
or
On Error Resume Next

'above

xSh.Select

This comment was minimized by the moderator on the site
1004 runtime error
This comment was minimized by the moderator on the site
Sub Dosomething()
Dim xSh As Worksheet
Application.ScreenUpdating = False
For Each xSh In Worksheets
xSh.Select
Call RunCode
Next
Application.ScreenUpdating = True
End Sub
Sub RunCode()
With Worksheets("2018")
.EnableOutlining = True
.EnableSelection = xlNoRestrictions
.Protect Password:="workana1234", _
Contents:=True, UserInterfaceOnly:=True
End With
End Sub


Hola! he seguido las pautras pero me señala como error la fila xSh.Select.

Al dar F5 me indica que se ha producido un error 1004 en tiempo de ejecucion.

Error en el metodo "Select" de Objeto "_Worksheet"



Help!!!!
This comment was minimized by the moderator on the site
On Error Resume Next
above
xSh.Select
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations