ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Finding all instances of ALT-ENTER on worksheet (https://www.excelbanter.com/excel-programming/364683-finding-all-instances-alt-enter-worksheet.html)

Barb Reinhardt

Finding all instances of ALT-ENTER on worksheet
 
I'd like to find all of the instances of ALT-ENTER on my worksheet and
highlight them. How would I do this? A VBA solution is fine.

Thanks,
Barb Reinhardt

Tom Ogilvy

Finding all instances of ALT-ENTER on worksheet
 
Sub FindAltEnter()
Dim rng As Range, rng1 As Range
Set rng = Cells.Find(What:=Chr(10), _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
sAddr = rng.Address
Do
If rng1 Is Nothing Then
Set rng1 = rng
Else
Set rng1 = Union(rng1, rng)
End If
Set rng = Cells.FindNext(rng)
Loop Until rng.Address = sAddr
End If
If Not rng1 Is Nothing Then
rng1.Select
Else
MsgBox "None found"
End If
End Sub


--
Regards,
Tom Ogilvy


"Barb Reinhardt" wrote:

I'd like to find all of the instances of ALT-ENTER on my worksheet and
highlight them. How would I do this? A VBA solution is fine.

Thanks,
Barb Reinhardt



All times are GMT +1. The time now is 04:22 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com