Hi I am writing a macro where the when the user press a commandbutton, the user will input the data he want to find and the macro will search the whole workbook(excluding sheet1) relating to what the user input.
The found cell value will then be copied and paste on sheet1 A1 and which sheet it is from on B1.
The cell A1 also need to be hyperlink thus the user can click the hyperlink and go to that specific sheet and cell to view more data on it.
eg.
[TABLE="width: 500"]
<tbody>[TR]
[TD]food[/TD]
[TD]Sheet5[/TD]
[/TR]
</tbody>[/TABLE]
this is my current code,
Sub myInput()
Dim myValue As String
Dim i As Integer
myValue = InputBox("Enter Search Input")
If myValue = "" Then
MsgBox ("No data found")
End If
Exit Sub
If IsError(CDbl(datatoFind)) = False Then datatoFind = CDbl(datatoFind)
For i = 2 To 4
Sheets(i).Activate
Next i
Cells.Find(What:=myValue, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Activate
If ActiveCell.value = myValue Then
Active.Sheet.ActiveCell.value.Copy Destination:=Sheets(1).cell("A1")
End If
End Sub
The problem i am facing now is the found data wasn't copy to sheet1 and i do not know how to hyperlink and copy the sheetname on to cellB1.
Hope you all can help me solve and find my errors
Thank you
The found cell value will then be copied and paste on sheet1 A1 and which sheet it is from on B1.
The cell A1 also need to be hyperlink thus the user can click the hyperlink and go to that specific sheet and cell to view more data on it.
eg.
[TABLE="width: 500"]
<tbody>[TR]
[TD]food[/TD]
[TD]Sheet5[/TD]
[/TR]
</tbody>[/TABLE]
this is my current code,
Sub myInput()
Dim myValue As String
Dim i As Integer
myValue = InputBox("Enter Search Input")
If myValue = "" Then
MsgBox ("No data found")
End If
Exit Sub
If IsError(CDbl(datatoFind)) = False Then datatoFind = CDbl(datatoFind)
For i = 2 To 4
Sheets(i).Activate
Next i
Cells.Find(What:=myValue, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Activate
If ActiveCell.value = myValue Then
Active.Sheet.ActiveCell.value.Copy Destination:=Sheets(1).cell("A1")
End If
End Sub
The problem i am facing now is the found data wasn't copy to sheet1 and i do not know how to hyperlink and copy the sheetname on to cellB1.
Hope you all can help me solve and find my errors
Thank you
Last edited: