Skip i'r prif gynnwys

Sut i ddod o hyd i werthoedd lluosog a'u disodli ar unwaith yn Excel?

doc lluosog dod o hyd i ddisodli 1

Fel y gwyddom i gyd, gallwn ddefnyddio swyddogaeth Dod o Hyd ac Amnewid i ddod o hyd i luosog yr un gell a rhoi gwerth yn ôl yr angen. Ond weithiau, mae angen i chi gymhwyso amnewidiad llawer i lawer ar yr un pryd. Er enghraifft, mae gen i ystod o ddata, a nawr rydw i eisiau disodli'r holl Afalau yn Afalau Coch, Orennau i Orennau Gwyrdd, Bananas i Bananas Melyn ac yn y blaen fel y dangosir sgrinluniau canlynol, a oes gennych chi unrhyw syniadau da i ddatrys y dasg hon Excel?

Darganfyddwch a disodli gwerthoedd lluosog ar unwaith gyda chod VBA


swigen dde glas saeth Darganfyddwch a disodli gwerthoedd lluosog ar unwaith gyda chod VBA

Os ydych wedi blino dod o hyd i'r gwerthoedd a'u disodli dro ar ôl tro, gall y cod VBA canlynol eich helpu i ddisodli gwerthoedd lluosog gyda'ch testunau angenrheidiol ar unwaith.

1. Crëwch eich amodau yr ydych am eu defnyddio sy'n cynnwys y gwerthoedd gwreiddiol a'r gwerthoedd newydd. Gweler y screenshot:

doc lluosog dod o hyd i ddisodli 2

2. Yna dal i lawr y ALT + F11 allweddi i agor y Ffenestr Microsoft Visual Basic for Applications.

3. Cliciwch Mewnosod > Modiwlau, a gludwch y cod canlynol yn ffenestr y Modiwl.

Cod VBA: Darganfyddwch a disodli gwerthoedd lluosog ar unwaith

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. Yna pwyswch F5 allwedd i redeg y cod hwn, yn y blwch prydlon popped allan, nodwch yr ystod ddata yr ydych am gael gwerthoedd newydd yn lle'r gwerthoedd.

doc lluosog dod o hyd i ddisodli 3

5. Cliciwch OK, ac mae blwch prydlon arall yn cael ei arddangos i'ch atgoffa i ddewis y meini prawf rydych chi'n cael eich creu yng ngham 1. Gweler y screenshot:

doc lluosog dod o hyd i ddisodli 4

6. Yna cliciwch OK, mae'r gwerthoedd newydd wedi'u disodli gan y gwerthoedd newydd yn ôl yr angen.

doc lluosog dod o hyd i ddisodli 5


Erthyglau cysylltiedig:

Sut i ddod o hyd i destun penodol a'i ddisodli mewn blychau testun?

Sut i ddod o hyd i destun mewn teitlau siart yn Excel?

Sut i ddod o hyd i destun a'i ddisodli o fewn sylwadau yn Excel?

Sut i newid sawl llwybr hypergyswllt ar unwaith yn Excel?

 

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!

 

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