find the sheet name based on the cell value

rvkcools

Board Regular
Joined
Mar 14, 2013
Messages
78
i have an employee names from range("c24") till empty cell the prog works. if the employee name sheet is not there then the prog popup a msg box, saying "no sheet" and continue finding with other employee name

i tried this but it throws error wen sheet of a particular employee name is not available

Sub emptest()
Dim tempname As String
Worksheets("team").Select
Range("c24").Select
Do While ActiveCell.Value <> ""
tempname = ActiveCell.Value
If ActiveCell.Value = tempname Then
Worksheets(tempname).Select
Else
MsgBox "no sheet"
End If
Worksheets("team").Select
ActiveCell.Offset(1, 0).Select
Loop
End Sub

please help me
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
try below code
Code:
Sub SelectSheetFromCellValue()
    Dim strSheet As String
    Sheets("team").Select
    Range("C24").Select
    Do While ActiveCell.Value <> ""
    Do While ActiveCell.Value <> ""
    strSheet = ActiveCell
    On Error GoTo Cycel:
    Sheets(strSheet).Select
    Sheets("team").Select
    ActiveCell.Offset(1, 0).Select
    Loop
Cycel:     MsgBox "No Sheet"
Sheets("team").Select
    ActiveCell.Offset(1, 0).Select
    Loop
    
End Sub
 
Upvote 0
try one more
Code:
Sub SelectSheetFromCellValue()
    Dim strSheet As String
    Sheets("team").Select
    Range("C24").Select
    Do While ActiveCell.Value <> ""
    strSheet = ActiveCell
    On Error Resume Next
    Sheets(strSheet).Select
    If Err.Number = 9 Then MsgBox "Sheet Not found."
    Sheets("team").Select
    ActiveCell.Offset(1, 0).Select
    Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,540
Members
449,038
Latest member
Guest1337

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top