Highlight the data within Excel wrapped cell being searched once found.

mb8marmed

New Member
Joined
Feb 15, 2020
Messages
11
Office Version
  1. 365
  2. 2021
  3. 2019
  4. 2016
  5. 2013
  6. 2011
  7. 2010
  8. 2007
  9. 2003 or older
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
Is there a way to highlight the word or data being searched in Excel if the data is within the wrapped cell? I am using the Ctrl + F to find the data, though it will direct me to the wrapped cell, I still have to read all the data in there.

Hope you can give me an advice to this issue. Thank you in advance.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Looking for code? This is very basic in case the answer is no - and I have no idea if you need a function or a sub, or how you intend to call it. You could call this example as ColourFound("some text goes here"). It will probably error out if the string is not found but as noted, you may not be looking for code anyway.

VBA Code:
Public Sub ColourFound(strToFind As String)
'colour text if found
Dim cel As Range
Dim intPos As Integer

Set cel = Cells.Find(what:=strToFind).Cells
intPos = InStr(1, cel, strToFind)
If intPos > 0 Then cel.Characters(Start:=intPos, Length:=Len(strToFind)).Font.Color = vbRed

End Sub
 
Upvote 0
Looking for code? This is very basic in case the answer is no - and I have no idea if you need a function or a sub, or how you intend to call it. You could call this example as ColourFound("some text goes here"). It will probably error out if the string is not found but as noted, you may not be looking for code anyway.

VBA Code:
Public Sub ColourFound(strToFind As String)
'colour text if found
Dim cel As Range
Dim intPos As Integer

Set cel = Cells.Find(what:=strToFind).Cells
intPos = InStr(1, cel, strToFind)
If intPos > 0 Then cel.Characters(Start:=intPos, Length:=Len(strToFind)).Font.Color = vbRed

End Sub
Hi Micron, I am looking for a VBA code that will trigger Excel to highlight the wrapped string or word once it is found using Ctrl+F.

Thank you
 
Upvote 0
Code would have to know what text that the Find and Replace dialog box has in its "Find What" textbox and I do not know how to get that or if it is even possible. Probably doable if you used your own userform since the userform would be available to other code. If you clicked a command button named CommandButton1 on the form and the text to find was in Textbox1 then perhaps something like (untested)
VBA Code:
Sub CommandButton1_Click()
'colour text if found
Dim cel As Range
Dim intPos As Integer
Dim strToFind As String

strToFind = Me.Textbox1
Set cel = ActiveSheet.Cells.Find(what:=strToFind).Cells
intPos = InStr(1, cel, strToFind)
If intPos > 0 Then cel.Characters(Start:=intPos, Length:=Len(strToFind)).Font.Color = vbRed

End Sub
If you can create a keyboard combination that is not being used, you could load your userform with it (e.g. alt+y) they way the find dialog is loaded.
 
Upvote 0

Forum statistics

Threads
1,223,248
Messages
6,171,027
Members
452,374
Latest member
keccles

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top