hi, i need to put the line below in the macro so that it can be more efficient
(instead of searching in the whole sheet it search in the range that i mention)
many thanks
Range(Cells(firstrow, firstCol), Cells(lastrow, lastCol)).Select
Sub trova()
Dim lunghezza As Byte
Dim separatore As Byte
Dim col As String
Dim rig As Long
Dim indirizzo As Variant
Dim testValue As Variant
Dim x As Variant
Dim FoundCell As Variant
testValue = InputBox("Enter the value to search for : ")
For Each x In ActiveWindow.SelectedSheets
x.Select
Set FoundCell = ActiveSheet.Cells.Find(testValue, LookIn:=xlValues, LookAt:=xlWhole, MatchCase:=True)
If FoundCell Is Nothing Then
MsgBox "The word was not found"
Else
indirizzo = FoundCell.Address
indirizzo = Trim(indirizzo)
indirizzo = Replace(indirizzo, Chr(36), "", 1, 1)
separatore = InStr(indirizzo, Chr(36))
lunghezza = Len(indirizzo)
col = Left(indirizzo, (separatore - 1))
rig = Right(indirizzo, (lunghezza - separatore))
LookAgain:
Set FoundCell = _
ActiveSheet.Cells.FindNext(After:=ActiveCell)
GoTo NextSheet
End If
NextSheet:
Next x
Range(col & rig).Select
End Sub
Bookmarks