Macro to find a value in a worksheet
Closed
azmiismail
Posts
17
Registration date
Thursday 3 March 2011
Status
Member
Last seen
20 July 2011
-
9 Mar 2011 à 22:51
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 - 10 Mar 2011 à 05:29
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 - 10 Mar 2011 à 05:29
Related:
- Macro to find a value in a worksheet
- Transfer data from one excel worksheet to another automatically - Guide
- How to run a macro in excel - Guide
- Run macro on opening: worksheet, workbook - Guide
- Add worksheet vba - Guide
- Copy worksheet to another workbook vba - Guide
1 response
rizvisa1
Posts
4478
Registration date
Thursday 28 January 2010
Status
Contributor
Last seen
5 May 2022
766
10 Mar 2011 à 05:29
10 Mar 2011 à 05:29
If you are new to macro, a very good starting point would be using macro recorder. It can give a general template for what you need.
Here is a macro that can do what you wanted
Here is a macro that can do what you wanted
Sub doExecuteSearch()
Dim sSearchFor As String
Dim rngCell As Range
Do
sSearchFor = InputBox("Please enter value to be searched", "Search")
If sSearchFor <> vbNullString _
Then
With Sheets("B2JT")
Set rngCell = .Range("a2:a9").Find(sSearchFor, .Cells(8, 1), , xlWhole, xlByRows, xlNext)
If Not rngCell Is Nothing _
Then
MsgBox "found at row " & rngCell.Row & " and column " & rngCell.Column
Else
MsgBox "Not found"
End If
End With
End If
Loop While sSearchFor <> vbNullString
End Sub