I have the following code (courtesy of watersev) that searches my workbook for a string and returns what sheet it resides in.
What i was hoping for that the sheetname it returns be in a hyperlink format, so that the user can click the sheetname and it automatically goes to that sheet.
i think the line below needs a clever change, but any help would be great.
Sub WheresmyAccount()
Dim lrow As Long, search_val As String, mainsh As Worksheet, Sh, acclrow As Long, renewal_row, iflag As Boolean
lrow = Cells(Rows.Count, 2).End(xlUp).Row
search_val = Range("a3")
Application.ScreenUpdating = False
Application.EnableEvents = 0
If lrow > 8 Then Range("b9", Cells(lrow, 3)).ClearContents
If Range("a3") = "" Then Exit Sub
Set mainsh = Sheets("Start")
For Each Sh In ActiveWorkbook.Sheets
If InStr("GraphsStartSummaryTemplateUsersBrokers", Sh.Name) = 0 Then
If Sh.Visible = True Then
If Sh.Range("a17").EntireRow.Hidden = True Then iflag = True Else iflag = False
With Sh.Range("C16:C190")
.AutoFilter 1, "*" & search_val & "*"
.Offset(1).Copy mainsh.Cells(Rows.Count, 2).End(xlUp).Offset(1)
acclrow = mainsh.Cells(Rows.Count, 2).End(xlUp).Row
renewal_lrow = mainsh.Cells(Rows.Count, 3).End(xlUp).Offset(1).Row
If acclrow >= renewal_lrow Then
With mainsh.Range("c" & renewal_lrow & ":c" & acclrow)
.NumberFormat = "@"
.Value = Sh.Name
End With
End If
.AutoFilter
If iflag = True Then Sh.Range("a17").EntireRow.Hidden = True
End With
End If
End If
Next
Range("B8:C37").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
.TintAndShade = 0
.Weight = xlThick
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
Range("B4").Select
Application.EnableEvents = 1
Application.ScreenUpdating = True
End Sub
Bookmarks