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

كيفية البحث عن قيم متعددة واستبدالها مرة واحدة في Excel؟

وثيقة متعددة ، استبدل 1

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

ابحث عن قيم متعددة واستبدلها مرة واحدة برمز VBA


السهم الأزرق الحق فقاعة ابحث عن قيم متعددة واستبدلها مرة واحدة برمز VBA

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

1. يرجى إنشاء الشروط التي تريد استخدامها والتي تحتوي على القيم الأصلية والقيم الجديدة. انظر لقطة الشاشة:

وثيقة متعددة ، استبدل 2

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

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

كود فبا: ابحث عن قيم متعددة واستبدلها مرة واحدة

Sub MultiFindNReplace()
'Updateby Extendoffice
Dim Rng As Range
Dim InputRng As Range, ReplaceRng As Range
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Original Range ", xTitleId, InputRng.Address, Type:=8)
Set ReplaceRng = Application.InputBox("Replace Range :", xTitleId, Type:=8)
Application.ScreenUpdating = False
For Each Rng In ReplaceRng.Columns(1).Cells
    InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value
Next
Application.ScreenUpdating = True
End Sub

4. ثم اضغط F5 مفتاح لتشغيل هذا الرمز ، في مربع المطالبة المنبثق ، يرجى تحديد نطاق البيانات الذي تريد استبدال القيم بقيم جديدة.

وثيقة متعددة ، استبدل 3

5. انقر OK، ويتم عرض مربع مطالبة آخر لتذكيرك بتحديد المعايير التي قمت بإنشائها في الخطوة 1. انظر لقطة الشاشة:

وثيقة متعددة ، استبدل 4

6. ثم اضغط OK، تم استبدال جميع القيم المحددة بالقيم الجديدة كما تريد على الفور.

وثيقة متعددة ، استبدل 5


مقالات ذات صلة:

كيفية البحث عن نص معين واستبداله في مربعات النص؟

كيفية البحث عن نص واستبداله في عناوين المخططات في Excel؟

كيفية البحث عن نص واستبداله داخل التعليقات في Excel؟

كيفية تغيير مسارات الارتباط التشعبي المتعددة مرة واحدة في 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 (136)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Sub MultiFindNReplace()
'Actualizar 20140722
Dim Rng As Range
Dim InputRng As Range, ReplaceRng As Range
xTitleId = "KutoolsforExcel"
Set InputRng = Application.Selection
Set InputRng = Application.InputBox("Original Range", xTitleId, InputRng.Address, Type:=8)
Set ReplaceRng = Application.InputBox("Replace Range:", xTitleId, Type:=8)
Application.ScreenUpdating = False
For Each Rng In ReplaceRng.Columns(1).Cells
InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value, LookAt:=xlWhole
Next
Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
amigo este post tiene como 8 años pero funciona, que buen aporte para los que no sabemos excel
This comment was minimized by the moderator on the site
Dei uma modificada no código, e no meu caso, as referências de células são estáticas:

Sub MetodoReplace()

Dim rng As Range, xTitleId As String
Dim inputRng As Range, replaceRng As Range

Application.ScreenUpdating = False

xTitleId = "Metodo Replace"
Set inputRng = Range("A1").CurrentRegion.Offset(1, 0)
Set inputRng = Application.InputBox("Original range:", xTitleId, inputRng.Range("A1").CurrentRegion.Address, _
Type:=8)
Set replaceRng = Application.InputBox("Reaplicar Range:", xTitleId, inputRng.Range("C2").CurrentRegion.Address, _
Type:=8)

For Each rng In replaceRng.Columns(1).Cells
inputRng.Replace What:=rng.Value, Replacement:=rng.Offset(0, 1).Value
Next

Application.ScreenUpdating = True
This comment was minimized by the moderator on the site
Благодарю за экономию моего времени! Успехов!
This comment was minimized by the moderator on the site
Hallo,

ich würde gerne den Text in den Tabellen des Jahresabschlusses automatisch von Deutsch ins Englische übersetzen.
Dazu habe ich eine Excel Arbeitsmappe in welchem die Übersetzungstabelle "Ersatz" enthalten ist und in den folgenden Tabellenblättern die verschiedenen Tabellen wie zb. die Konzernbilanz, GuV, Geldflussrechnung etc.
Dazu habe ich ihren Code versucht zu transformieren. Die Übersetzung erfolgt im Grunde auch, aber zb. Vermögen - Assets; Finanzielle Vermögenswerte - Financial Assets wird nicht korrekt übersetzt, die Finanziellen Vermögenswerte übersetzt es als "Financial Assetswerte". auch in thousands EUR wir offensichtlich mit USA kombiniert.

Hier der Code (meine VBA Kenntnisse sind nur sehr minimalistisch):
Sub MultiFindNReplace2()
'Updateby Alex
Dim Rng As Range
Dim InputRng As Range, ReplaceRng As Range
Dim Ws As Worksheet

Set Ws = Worksheets("Konzernbilanz")
Set Ws = Worksheets("Konzerngesamtergebnis")
Set Ws = Worksheets("Konzerneigenkapitalspiegel")
Set Ws = Worksheets("Konzerngeldfluss")
Set InputRng = Ws.Range("D:Z")

Set Ws = Worksheets("Ersatz")
Set ReplaceRng = Ws.Range("A:B")

Application.ScreenUpdating = False
For Each Rng In ReplaceRng.Columns(1).Cells
InputRng.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value
Next
Application.ScreenUpdating = True
End Sub

Evtl. haben sie auch eine Idee wie ich dem Programm sagen kann, dass alle Tabellenblätter übersetzt werden müssen, außer natürlich die Tabelle "Ersatz".

Vielen Dank

Sg
Alex
This comment was minimized by the moderator on the site
Buenas !

Sabe alguien si se puede ejecutar en varias hojas de un mismo excel simultaneamente ?


Muchas gracias !!!
This comment was minimized by the moderator on the site
Hello, Roman,
If you want to find and replace in multiple worksheets, the following VBA code may do you a favor.
Note: Sheet1, Sheet2 are the sheet names that you want to find and replace values from, please separate the sheet names by comma; A1:AA100is the original data range you want to replace the specific values.
Sub MultiFindNReplace()
'Updateby Extendoffice
Dim xArrSh()
Dim Rng As Range
Dim xStrRgAddress As String
Dim InputRng As Range, ReplaceRng As Range
Dim xCells As Range
Dim xWSHs As Sheets
Dim xWSh As Worksheet
xArrSh = Array("Sheet1", "Sheet2") 'The sheet names, please separate the sheet names by comma
xStrRgAddress = "A1:AA100" 'the original data range you want to replace
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set ReplaceRng = Application.InputBox("Replace Range :", xTitleId, Type:=8)
If ReplaceRng Is Nothing Then Exit Sub
Set xWSHs = Application.ActiveWorkbook.Worksheets
Application.ScreenUpdating = False
For xI = 0 To UBound(xArrSh)
Set xWSh = xWSHs(xArrSh(xI))
Set xCells = xWSh.Range(xStrRgAddress)
For Each Rng In ReplaceRng.Columns(1).Cells
    xCells.Replace what:=Rng.Value, replacement:=Rng.Offset(0, 1).Value
Next
Next
Application.ScreenUpdating = True
End Sub


After inserting the code, run this code, and a prompt box will pop up, select the original data and new data you want to find and replace with. see screenshot:
https://www.extendoffice.com/images/stories/comments/comment-skyyang/doc-multiple-find-replace.png

Please try, hope it can help you!
This comment was minimized by the moderator on the site
Olá amigos o código é interessante porem não consegui que funciona-se ficarei muito grato se alguém se dispor a ajuda tenho certeza que será útil para outras pessoas.
exemplo:
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 20 21 22 23 25
tenho esses números em uma linha
2 4 5 9 10 11 12 14 15 17 18 20 21 22 25
2 3 4 5 6 8 9 10 11 16 17 18 20 22 23
2 3 4 5 6 7 8 10 11 12 14 15 16 21 22
2 3 4 7 8 10 11 13 14 15 17 20 22 23 25
2 3 8 9 10 11 12 13 14 16 18 20 21 23 25
2 5 6 7 8 9 11 12 13 15 17 18 21 22 23
3 4 6 7 9 11 12 14 15 16 17 18 20 23 25
2 3 4 6 7 8 9 13 14 16 17 18 21 22 25
3 5 6 10 13 14 15 16 17 18 20 21 22 23 25
2 4 5 6 7 8 9 10 12 13 15 16 17 20 25
e esse grupo em outras porem preciso localizar e substituir e criar vinculo das células com seus respectivos números
exemplo: 02 com 02, 03 com 03, 04 com 04
att: Rosemar
This comment was minimized by the moderator on the site
Hello friend,

Sorry to hear that. Your situation is different from the example in the article. Our VBA code can only replace the original values with the value you define. It can't create a link between the cells with their respective numbers. Sorry for that. Have a nice day.

Sincerely,
Mandy
This comment was minimized by the moderator on the site
Bonjour,
merci pour votre support. Cela répond presque à mon besoin.Par contre, comment faire quand la même valeur se trouve dans "Origine value" et "Replacing value" car la valeur modifiée redevient la valeur d'origine ?Exemple : Origine value    ->    Replacing value
 
13h - 21h  ->  5h - 13h
8h - 16h   -> 10h - 18h
10h - 18h  ->  8h - 16h

Merci par avance pour votre aide
This comment was minimized by the moderator on the site
hello can we change also color ?  ex : i wanna change apple to red apple with the red filled cell
This comment was minimized by the moderator on the site
Is this method can be use if between sentence in a cell?e.g I want to change numbers between the line : abcdefghi 12345 jklmnopqrstu >>> abcdefghi 67891 jklmnopqrstu

if no is there any other method can be use? Please help. Thank you!
This comment was minimized by the moderator on the site
Hello, qill,The code in this article can finish your problem, please try, thank you!

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