Skip to main content

Conas gach focal sonrach a chló i raon cealla?

doc téacs trom sonrach 1

In Excel, an Aimsigh agus Ionadaigh is féidir le feidhm cabhrú linn téacs ar leith a aimsiú agus formáidiú trom nó aon fhormáidiú eile a thabhairt do na cealla iomlána. Ach an ndearna tú iarracht riamh an téacs sonrach i gcealla seachas an chill iomlán a chló mar a thaispeántar thíos:

Trom gach focal sonrach i raon cealla le cód VBA


mboilgeog cheart gorm saighead Trom gach focal sonrach i raon cealla le cód VBA

D’fhéadfadh an cód VBA seo a leanas cabhrú leat an téacs sonrach in ábhar cille a chló trom, déan mar a leanas:

1. Coinnigh síos an ALT + F11 eochracha a oscailt Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

2. Cliceáil Ionsáigh > Modúil, agus greamaigh an cód seo a leanas sa Modúil Fuinneog.

Cód VBA: Téacs trom sonrach i raon cealla

Sub FindAndBold()
'Updateby Extendoffice 20160711
    Dim xFind As String
    Dim xCell As Range
    Dim xTxtRg As Range
    Dim xCount As Long
    Dim xLen As Integer
    Dim xStart As Integer
    Dim xRg As Range
    Dim xTxt As String
    On Error Resume Next
    If ActiveWindow.RangeSelection.Count > 1 Then
      xTxt = ActiveWindow.RangeSelection.AddressLocal
    Else
      xTxt = ActiveSheet.UsedRange.AddressLocal
    End If
    Set xRg = Application.InputBox("Please select data range:", "Kutools for Excel", xTxt, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    On Error Resume Next
    Set xTxtRg = Application.Intersect(xRg.SpecialCells(xlCellTypeConstants, xlTextValues), xRg)
    If xTxtRg Is Nothing Then
        MsgBox "There are no cells with text"
        Exit Sub
    End If
    xFind = Trim(Application.InputBox("What do you want to BOLD?", "Kutools for Excel", , , , , , 2))
    If xFind = "" Then
        MsgBox "No text was listed", vbInformation, "Kutools for Excel"
        Exit Sub
    End If
    xLen = Len(xFind)
    For Each xCell In xTxtRg
        xStart = InStr(xCell.Value, xFind)
        Do While xStart > 0
            xCell.Characters(xStart, xLen).Font.Bold = True
            xCount = xCount + 1
            xStart = InStr(xStart + xLen, xCell.Value, xFind)
        Loop
    Next
    If xCount > 0 Then
        MsgBox "number of " & CStr(xCount) & " text be bolded!", vbInformation, "Kutools for Excel"
    Else
        MsgBox "Not find the specific text!", vbInformation, "Kutools for Excel"
    End If
End Sub

3. Ansin brúigh F5 eochair chun an cód seo a rith, agus tá bosca pras popped amach chun a mheabhrú duit an raon sonraí a theastaíonn uait a chló a roghnú, féach an scáileán:

doc téacs trom sonrach 2

4. Agus ansin cliceáil OK, tiocfaidh bosca eile amach le cur i gcuimhne duit an téacs sonrach nach dteastaíonn uait a chló ach i gcealla a iontráil, féach an scáileán:

doc téacs trom sonrach 3

5. Tar éis duit an téacs a iontráil, cliceáil le do thoil OK cnaipe, agus an téacs go léir a shonraigh tú curtha i gcló trom sa raon roghnaithe, féach an scáileán:

doc téacs trom sonrach 4

Uirlisí Táirgiúlachta Oifige is Fearr

🤖 Kutools AI Aide: anailís sonraí a réabhlóidiú bunaithe ar: Forghníomhú Chliste   |  Gin Cód  |  Cruthaigh Foirmlí Saincheaptha  |  Anailís a dhéanamh ar Sonraí agus Cairteacha a Ghin  |  Feidhmeanna Kutools a agairt...
Gnéithe Coitianta: Faigh, Aibhsigh nó Aithnigh Dúblaigh   |  Scrios Sraitheanna Bána   |  Comhcheangail Colúin nó Cealla gan Sonraí a Chailleadh   |   Babhta gan Foirmle ...
Cuardaigh Super: Ilchritéir VLookup    VLookup Illuachanna  |   VLookup Trasna Ilbhileoga   |   Amharc doiléir ....
Liosta anuas Casta: Go tapa Cruthaigh Liosta Anuas   |  Liosta anuas Cleithiúnach   |  Liosta Buail Isteach Ilroghnacha ....
Bainisteoir Colún: Cuir Líon Sonrach Colún leis  |  Colúin Bog  |  Scoránaigh Stádas Infheictheachta na gColún Ceilte  |  Déan comparáid idir Raonta & Colúin ...
Gnéithe Réadmhaoin: Fócas Eangaí   |  Amharc Dearaidh   |   Barra Mór na Foirmle    Leabhar Oibre & Bainisteoir Bileog   |  Leabharlann Acmhainní (Uaththéacs)   |  Piocálaí Dáta   |  Comhcheangail Bileoga Oibre   |  Criptigh/Díchriptigh Cealla    Seol Ríomhphost trí Liosta   |  Scagaire Super   |   Scagaire Speisialta (scagaire trom/iodálach/stailc tríd...) ...
Barr 15 Uirlisí12 Téacs uirlisí (Cuir Téacs, Bain Carachtair,...)   |   50 + Cairt cineálacha (Cairt Gantt,...)   |   40+ Praiticiúil Foirmlí (Ríomh aois bunaithe ar lá breithe,...)   |   19 Insertion uirlisí (Cuir isteach Cód QR, Ionsáigh Pictiúr ón gCosán,...)   |   12 Tiontú uirlisí (Uimhreacha le Focail, Comhshó Airgeadra,...)   |   7 Cumaisc & Scoilt uirlisí (Sraitheanna Comhcheangail Casta, Cealla Scoilt,...)   |   ... agus eile

Supercharge Do Scileanna Excel le Kutools le haghaidh Excel, agus Éifeachtúlacht Taithí Cosúil Ná Roimhe. Kutools le haghaidh Excel Tairiscintí Níos mó ná 300 Ardghnéithe chun Táirgiúlacht a Treisiú agus Sábháil Am.  Cliceáil anseo chun an ghné is mó a theastaíonn uait a fháil ...

Tuairisc


Tugann Tab Oifige comhéadan Tabbed chuig Office, agus Déan Do Obair i bhfad Níos Éasca

  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
Comments (10)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
Worked perfectly fine for me. I track leases and the documents that need to be submitted by agents. I put "none" in the cells for the leases that have had all docs turned in. Bolding the words makes it easier to read!

Thanks again for the help!
Rated 5 out of 5
This comment was minimized by the moderator on the site
Awesome! Worked great!
This comment was minimized by the moderator on the site
I get the first pop up hit ok but then don't get the second pop up window to type in the word?
This comment was minimized by the moderator on the site
I attempted to run this code and just got an error..."Compile Error: Wrong # of arguments or invalid property assignment". Below is the image of the error message and the breakpoint of the code.
This comment was minimized by the moderator on the site
Hello, Sherry,
I can not see your screenshot, please upload it again.
Thank you!
This comment was minimized by the moderator on the site
Hello, its possible to search multiple text and bold that text PLUS that cell line. (I have 1 cell with 5 lines, i want to bold the line if find "1º", if rest like "2º" "3º" , "number + º " bold only number.)

Other need is:
If find "1º" bold that cell line
This comment was minimized by the moderator on the site
Can this VBA be modified to bold multiple texts, such as "KTE", "KTO", and "KTW"?
This comment was minimized by the moderator on the site
Hello, Eric,

May be the following VBA code can help you to bold multiple specific cell, please apply the below code.
Sub FindAndBold()
Dim I As Long
Dim xFind As String
Dim xCell As Range
Dim xTxtRg As Range
Dim xCount As Long
Dim xLen As Integer
Dim xStart As Integer
Dim xRg As Range, xRgFind As Range
Dim xTxt As String
Dim xArr() As String
On Error Resume Next
If ActiveWindow.RangeSelection.Count > 1 Then
xTxt = ActiveWindow.RangeSelection.AddressLocal
Else
xTxt = ActiveSheet.UsedRange.AddressLocal
End If
Set xRg = Application.InputBox("Please select data range:", "Kutools for Excel", xTxt, , , , , 8)
If xRg Is Nothing Then Exit Sub
On Error Resume Next
Set xTxtRg = Application.Intersect(xRg.SpecialCells(xlCellTypeConstants, xlTextValues), xRg)
If xTxtRg Is Nothing Then
MsgBox "There are no cells with text"
Exit Sub
End If
Set xRgFind = Application.InputBox("Select the text cells you want to bold", "Kutools for Excel", , , , , , 8)
If xRgFind Is Nothing Then
MsgBox "No text was listed", vbInformation, "Kutools for Excel"
Exit Sub
End If
ReDim xArr(xRgFind.Count - 1)
For I = 0 To (xRgFind.Count - 1)
xArr(I) = xRgFind(I + 1)
Next
For Each xCell In xTxtRg
For I = 0 To UBound(xArr)
xFind = Trim(xArr(I))
xStart = InStr(xCell.Value, xFind)
xLen = Len(xFind)
Do While xStart > 0
xCell.Characters(xStart, xLen).Font.Bold = True
xCount = xCount + 1
xStart = InStr(xStart + xLen, xCell.Value, xFind)
Loop
Next
Next
If xCount > 0 Then
MsgBox "number of " & CStr(xCount) & " text be bolded!", vbInformation, "Kutools for Excel"
Else
MsgBox "Not find the specific text!", vbInformation, "Kutools for Excel"
End If
End Sub

Hope it can help you, thank you!
This comment was minimized by the moderator on the site
Hello skyyang, can you help me out in my excel?
If find "1º" in a cell with several lines, bold that cell line
This comment was minimized by the moderator on the site
if I want to make bold the string G-AD only it doesn t work if i have in my cell G-AD and G-AD-bla-bla-bla (this G-AD should not be made BOLD)
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations