Note: The other languages of the website are Google-translated. Back to English

Cum se înlocuiește textul cu imagini corespunzătoare în Excel?

doc înlocuiește textul cu imaginea 1 2 doc înlocuiește textul cu imaginea 2

Să presupunem că am o listă de nume de produse într-o foaie de lucru și există un folder care conține imaginile corespunzătoare ale numelor de produse pe discul computerului. Acum, trebuie să găsesc și să înlocuiesc numele produselor cu imaginile lor relative în Excel fără să le inserez pe rând, după cum se arată în următoarele capturi de ecran. Există soluții bune și rapide pentru a face față acestui job în Excel?

Înlocuiți textul cu imaginile corespunzătoare cu codul VBA

Înlocuiți textul cu imaginile corespunzătoare cu Kutools pentru Excel

Înlocuiți textul cu imaginile corespunzătoare cu codul VBA

În mod normal, nu există o modalitate ușoară și directă de a insera imaginile relative pe baza șirului de text în Excel, dar, următorul cod VBA vă poate ajuta să înlocuiți textul cu imaginea corespunzătoare.

1. Anunturi Alt + F11 pentru a afișa Microsoft Visual Basic pentru aplicații fereastră.

2. În fereastră, faceți clic pe Insera > Module pentru a afișa o nouă fereastră de modul, apoi copiați și lipiți următorul cod VBA în modul fereastră.

Cod VBA: înlocuiți textul cu imaginile corespunzătoare

Sub InsertPicture()
'Upadateby Extendoffice
Dim xPath As String
Dim xLastRow As Long
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)
Application.ScreenUpdating = False
xPath = "C:\Users\dt\Desktop\Fruits\"
If Right(xPath, 1) <> "\" Then xPath = xPath & "\"
xLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For Each Rng In WorkRng
    If Rng.Value <> "" Then
        If Dir(xPath & Rng.Value & ".jpg") <> "" Then
            ActiveSheet.Pictures.Insert(xPath & Rng.Value & ".jpg").Select
            With Selection.ShapeRange
                .LockAspectRatio = msoFalse
                .Left = Rng.Left
                .Top = Rng.Top
                .Width = Rng.Width
                .Height = Rng.Height
            End With
            Rng.Value = "N/A"
        End If
    End If
Application.ScreenUpdating = True
End Sub

3. Then press F5 key to run this code, and select the data range that you want to insert the corresponding pictures in the popped out dialog, see screenshot:

doc replace text with image 3

4. And then click OK button, all the corresponding images with the size as the same as the cells will be replaced with the original text, see screenshots:

doc replace text with image 4  2 doc replace text with image 5


1. In the above code, you need to change the folder path of the pictures to your need, xPath = "C:\Users\dt\Desktop\Fruits\".

2. If there are no corresponding pictures to match the text, the error N/A will display.

Replace text with corresponding pictures with Kutools for Excel

As the above code difficult to master, here, I will introduce you an easy and powerful tool - Kutools for Excel, with its Match Import Pictures feature, you can quickly and conveniently to insert the pictures to match the list of text.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 30 days. 

After installing Kutools for Excel, please do as this:

1. Click Kutools Plus > Import & Export > Match Import Pictures, see screenshot:

2. In the Match Import Pictures dialog box, click doc replace text button 1 button to select the range that you want to match with the pictures, see screenshot:

doc replace text with image 7 7

3. Then in the Match Import Pictures dialog, click Add > File or Folder to find the pictures that you want to insert, see screenshot:

doc replace text with image 8 8

4. After inserting the corresponding images, then click Import size button, in the following Import Picture Size dialog, specify one option for the size of your picture. See screenshot:

doc replace text with image 9 9

5. Then click OK > Import, and then choose one cell to locate your relative images from the popped out Match Import Pictures dialog (you can also select the original cell of the text), see screenshot:

doc replace text with image 10 10

6. And then click OK button, all the pictures which match with the text have been inserted into the worksheet, see screenshot:

doc replace text with image 11 11


1. If there are no matched pictures with the text, the cell will not insert anything.

2. If you want to insert pictures horizontally, you can check Fill horizontally cell after cell in the Import order section.

Download and free trial Kutools for Excel Now !

Demo: Replace text with corresponding pictures with Kutools for Excel

Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days. Download and free trial Now!

The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office / Excel 2007-2021 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations

Follow Us

Copyright © 2009 - | All rights reserved. Powered by ExtendOffice. | Sitemap
Microsoft and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.
Protected by Sectigo SSL