SanjayGMusafir
Well-known Member
- Joined
- Sep 7, 2018
- Messages
- 1,513
- Office Version
- 2024
- Platform
- Windows
Hi Experts
I have fiel where I put 10 to 12 digit numbers. The Column is formatted as "##### #####" to give a space to make number readable like in India.
If I input "1234567890" it shows me "12345 67890"
Now I'm using a VBA that searches and return from xLValues. It works perfect if I search for an thing in output format. for eg. "12345 67890"
Just now got in a situation where I need to search by "1234567890" and it should take me to the cell where "12345 67890" is displayed.
Any help is highly appreciated.
Thanks a lot
This is the complete code I'm using right now -
I experimented changing a part of FIND from "xlValues" to "xlFormulas" but it didn't work. Probably, I'm missing some trick.
I have fiel where I put 10 to 12 digit numbers. The Column is formatted as "##### #####" to give a space to make number readable like in India.
If I input "1234567890" it shows me "12345 67890"
Now I'm using a VBA that searches and return from xLValues. It works perfect if I search for an thing in output format. for eg. "12345 67890"
Just now got in a situation where I need to search by "1234567890" and it should take me to the cell where "12345 67890" is displayed.
Any help is highly appreciated.
Thanks a lot
This is the complete code I'm using right now -
VBA Code:
Sub SearchSheet()
'
' SearchSheet Macro
'
'
Dim xRng As Range
x = Application.InputBox("", "Search for...")
'To reset Zoom levels of the sheet
Call ZoomReset
Application.ScreenUpdating = True
Range("A1").Select
If x = "" Then 'if Search Input is Blank
MsgBox "Blank Search..."
Exit Sub
ElseIf x = False Then 'If Search is Cancelled
MsgBox "You Cancelled..."
Exit Sub
Else
Set xRng = Cells.Find(What:=x, After:=ActiveCell, LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False)
If xRng Is Nothing Then 'If No Result Found
MsgBox "No Search Result Found..."
Exit Sub
Else
xRng.Select 'When Result is Found
End If
End If
End Sub
I experimented changing a part of FIND from "xlValues" to "xlFormulas" but it didn't work. Probably, I'm missing some trick.
VBA Code:
Set xRng = Cells.Find(What:=x, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
MatchCase:=False)