How to replace all number on Excel Sheet with text on same sheet

hi Experts
i have time attendance machine export the employment attendance report in Excel like this

Sheet 1
                                employee                  Time
                                     1                     08:00 AM    1-1-2015
                                     1                     16:00 PM    1-1-2015
                                     2                     08:01 AM    1-1-2015
                                     2                     16:00 PM    1-1-2015
                                     3                     08:00 AM    1-1-2015
                                     3                     16:00  PM   1-1-2015
                                   

While i have an excel sheet with employments names and number like that

Sheet 2
                               Employe Number       Employe Name
                                     1                              michael
                                     2                              mas
                                     3                              edward

all i need to replace the number on sheet 1 to be the name on sheet 2 to be like this

                                  Employee                                  Time
                                     michael                     08:00 AM    1-1-2015
                                     michael                    16:00 PM    1-1-2015
                                     mas                          08:01 AM    1-1-2015
                                     mas                          16:00 PM    1-1-2015
                                     edward                     08:00 AM    1-1-2015
                                     edward                    16:00  PM   1-1-2015
MASWORLDAsked:
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.

Rgonzo1971Commented:
HI,

you could use a helper's column and this formula and the copy and paste the value to right place

=VLOOKUP(A2,Sheet2!$A$2:$B$5,2)

Regards
0
Martin LissOlder than dirtCommented:
Or you can use this macro. It assumes that the names of the sheets are actually Sheet1 and Sheet2 and that the data on both sheets starts in column A.

Sub NumbersToNames()

Dim wsNumbers As Worksheet
Dim wsNames As Worksheet
Dim lngLastRowNbrs As Long
Dim lngLastRowNames As Long
Dim lngRowNbrs As Long
Dim lngRowNames As Long

Set wsNumbers = Sheets("Sheet1")
Set wsNames = Sheets("Sheet2")

lngLastRowNbrs = wsNames.Range("A1048576").End(xlUp).Row
lngLastRowNames = wsNames.Range("A1048576").End(xlUp).Row

For lngRowNbrs = 2 To lngLastRowNbrs
    For lngRowNames = 2 To lngLastRowNames
        With wsNumbers
            If .Cells(lngRowNbrs, "A") = wsNames.Cells(lngRowNames, "A") Then
                .Cells(lngRowNbrs, "A") = wsNames.Cells(lngRowNames, "B")
            End If
        End With
    Next
Next

End Sub

Open in new window


My apologies if you already know how to add a macro but just in case...

In Excel, Press Alt+F11 to open Visual Basic Editor (VBE)

Right-click on your workbook name in the "Project-VBAProject" pane (at the top left corner of the editor window) and select Insert -> Module from the context menu

Copy the macro (you can use the ‘Select All’ button if you like) and paste it into the right-hand pane of the VBA editor ("Module1" window)

Press Alt+F11 again to go back to Excel

Optionally, press Alt+F8 to open the "Macro" dialog window. Select the macro, click ‘Options…’,  hold down the Shift key and type the letter A (or any other letter) and click ‘OK’.  Then anytime you want to run the macro press Ctrl+Shift+A
0
MASWORLDAuthor Commented:
@Martin Liss thanks
many respect
i did all command
first i got this error
eri click on debug
err
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Martin LissOlder than dirtCommented:
Change line 13 in my post ID: 40846528 to

lngLastRowNbrs = wsNumbers.Range("A1048576").End(xlUp).Row

Are the sheets named "Sheet1" and "Sheet2"?
Does the data on both sheets start in column "A"?
0
MASWORLDAuthor Commented:
Are the sheets named "Sheet1" and "Sheet2"?
yes sheet1 num  sheet2 names

Does the data on both sheets start in column "A"?
yes num in column "A" in sheet1 name in column "A" in sheet2
0
MASWORLDAuthor Commented:
@Martin Liss
here is screen shot of sheet
12
0
Martin LissOlder than dirtCommented:
Can you attach your workbook please?
0
MASWORLDAuthor Commented:
ok
21.xlsx
0
Martin LissOlder than dirtCommented:
Sub NumbersToNames()

Dim wsNumbers As Worksheet
Dim wsNames As Worksheet
Dim lngLastRowNbrs As Long
Dim lngRowNbrs As Long

Set wsNumbers = Sheets("Sheet1")
Set wsNames = Sheets("Sheet2")

lngLastRowNbrs = wsNumbers.Range("A1048576").End(xlUp).Row

For lngRowNbrs = 2 To lngLastRowNbrs
    With wsNumbers
        .Cells(lngRowNbrs, "A") = wsNames.Cells(.Cells(lngRowNbrs, "A"), "A")
    End With
Next

End Sub

Open in new window

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
MASWORLDAuthor Commented:
Many thanks for help Excellent :)
0
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2015
0
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.