GomaPile
Active Member
- Joined
- Jul 24, 2006
- Messages
- 334
- Office Version
- 365
- Platform
- Windows
Hi all, how is everyone doing, it’s been a while since my last post.
Is there someone who’s able to help us that would be super appreciated for our Hospital Uniform Department.
VBA below was found browsing through Google, weblink provided will take you there (it’s safe).
The VBA does what it supposed to do which is find data within the excel, and we did add our bit too.
The VBA is very similar to the build-in FIND FUNCTION that you and I have on all computers today.
Though the difference between the VBA one from Google and build-in FIND FUNCTION both have their Pros & Cons, but we would love to see them All-In-One. Well to be openly 100% honest to everyone, we’re hoping that someone can help us who knows VBA. Anyways, I tried myself – but sadly no luck.
Build-in FIND FUNCTION:
Regards,
Gomapile (NASA2)
Is there someone who’s able to help us that would be super appreciated for our Hospital Uniform Department.
VBA below was found browsing through Google, weblink provided will take you there (it’s safe).
The VBA does what it supposed to do which is find data within the excel, and we did add our bit too.
The VBA is very similar to the build-in FIND FUNCTION that you and I have on all computers today.
Though the difference between the VBA one from Google and build-in FIND FUNCTION both have their Pros & Cons, but we would love to see them All-In-One. Well to be openly 100% honest to everyone, we’re hoping that someone can help us who knows VBA. Anyways, I tried myself – but sadly no luck.
Build-in FIND FUNCTION:
- Pros: goes straight to that cell and cycles through to the next matching info & onwards.
- Cons: doesn’t highlight the cells yellow.
- Pros: highlights all matching info in yellow.
- Cons: though it doesn’t go straight to the first cell or cycles through to the next.
- Highlight all matching cells in Yellow and go to the first highlighted Cell
- The ability to cycle Back and Forth onto the next cell
- Range: only lookup in Columns C and D
VBA Code:
'Website https://www.extendoffice.com/documents/excel/5839-excel-search-and-highlight-results.html
Private Sub CommandButton1_Click()
Dim xRg As Range
Dim xFRg As Range
Dim xStrAddress As String
Dim xVrt As Variant
Application.EnableEvents = False
Application.ScreenUpdating = False
Sheets("Orders").Unprotect Password:="test" '---- change the password to your liking's
xVrt = Application.InputBox(prompt:="Search:", Title:="Search Tool...")
If xVrt <> "" Then
Set xFRg = ActiveSheet.Cells.Find(what:=xVrt)
If xFRg Is Nothing Then
MsgBox prompt:="Cannot find this employee", Title:="Search Tool Completed..."
Exit Sub
End If
xStrAddress = xFRg.Address
Set xRg = xFRg
Do
Set xFRg = ActiveSheet.Cells.FindNext(After:=xFRg)
Set xRg = Application.Union(xRg, xFRg)
Loop Until xFRg.Address = xStrAddress
If xRg.Count > 0 Then
xRg.Interior.ColorIndex = 6
If xRsp = vbOK Then xRg.Interior.ColorIndex = xlNone
End If
End If
xRg.Areas(xRg.Areas.Count)(1).Select
Sheets("Orders").Protect Password:="test" '---- change the password to your liking's
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Regards,
Gomapile (NASA2)