How to check for a value in different tabs in excel?

Hi,

I have an excel sheet which has around 25 tabs. There is a master sheet which has names of all employees in our system. I have to use the employee name from this master sheet and search for occurrence of this name in any of the other sheets. If any occurrence is found, I need to have the sum of salary in those excel tabs corresponding to the employee name displayed in my master sheet.

For example, I have Employee Name John in my master sheet. If John appears in sheet 5, 6 and 10. I need to find the value of salary in those 3 excel tabs corresponding to John and then display in my main tab the sum of all salary for John.

Thanks for any help.

Regards
Ali.
bhagataliAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SiddharthRoutCommented:
A sample file is definitely required as you have bot mentioned which column has the salary. If you can upload a sample file then I can give you the code.

Sid
0
smartchapsCommented:
As you said will these tabs sheets) 5, 6 and 10 contain salary for only John or other employees also. Can you attach these sheets including Master sheet so that exact format of data in those sheets is known and solution is provided.
0
SiddharthRoutCommented:
Tried and Tested.

Sample Attached. Please amend as applicable. I have created a Userdefined Function so that all you need to do is use this formula in the cell

=CalcSal(A2)

Where A2 contains "John"

Sid

Code Used

Option Explicit

Public Function CalcSal(strEmployee As String) As Double
    Dim TotSal As Double
    Dim ws As Worksheet
    Dim acell As Range
    
    On Error GoTo whoa
    
    Application.ScreenUpdating = False
    
    For Each ws In ActiveWorkbook.Sheets
        If ws.Name <> ActiveSheet.Name Then
            '~~> Column where the name is. Ex: If the name is in Col A then 1
            Set acell = ws.Columns(1).Find(What:=strEmployee, LookIn:=xlValues, _
            LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False)
        
            If Not acell Is Nothing Then
                '~~> If the salary is in Col B then offset 1 of Col A
                '~~> If the salary is in Col C then offset 2 of Col A and so on
                TotSal = TotSal + acell.Offset(, 1).Value
            End If
        End If
    Next ws
    
    CalcSal = TotSal

letsContinue:
    Application.ScreenUpdating = True
    Exit Function
whoa:
    MsgBox Err.Description
    Resume letsContinue
End Function

Open in new window

Salary-Calculator.xls
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Rob HensonFinance AnalystCommented:
You could use a pivot table with multiple data sources but I don't have much experience of this  other than knowing it is possible.

Cheers
Rob H
0
bhagataliAuthor Commented:
Thanks for your inputs. I am attaching a sample file which shows what we intend to achieve.

Regards
Ali. Sample.xlsx
0
SiddharthRoutCommented:
Here I have updated the code and pasted the formula. Check the Yellow Cells.

Sid
Salary-Example.xls
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.