Hello, You can improve the performance using the following code: '----------------------- Sub write_equal()
Sheets("sheet2").Select Range("a2").Select Dim nameArtist As String Dim searchArea As Range Dim vlook Set searchArea = Sheets("sheet1").Range("a2:b100") Do While Not IsEmpty(ActiveCell) nameArtist = ActiveCell.Value On Error Resume Next vlook = Excel.WorksheetFunction.VLookup(nameArtist, searchArea, 2, False) If Err.Number > 0 Then ActiveCell.Offset(0, 1).Value = " We haven't this name insheet1 or That name is not equal in sheet1's name" Else ActiveCell.Offset(0, 1).Value = WorksheetFunction.VLookup(nameArtist, searchArea, 2, False) End If ActiveCell.Offset(1, 0).Select Loop End Sub '============= Akhilesh Kumar Karna Let us make a habit of using 'option explicit' at the top of macro On Wed, Feb 4, 2009 at 11:41 PM, 2008ra...@gmail.com <2008ra...@gmail.com>wrote: > > Hi, > > i have two sheets and i have tables in that sheets...and my table like > below format.and i wanna write sheet1's costs in sheet2 cost > area...but that sheet2 's name sometimes not equal that sheet1's name > and sometimes sheet1 not have sheet2's name , i was write that below > code but that is give error code " run-time error '1004' "...how can i > do that? > > Sub write_equal() > > Sheets("sheet2").select > range("a2").select > do while not isempty(activecell) > > nameartist = activecell.value > searcharea = Sheets("sheet1").range("a2:b100") > > if iserror(worksheetfunction.vlookup(nameartist,searcharea, > 2,false))=true then > activecell.offset(0,1).value = " We haven't this name in > sheet1 or That name is not equal in sheet1's name" > else > activecell.offset(0,1).value = worksheetfunction.vlookup > (nameartist,searcharea,2,false) > end if > > activecell.offset(1,0).select > > loop > > end sub > > -------------------------------------------------------------------- > that is sheets 1 > _| A | B > 1|---------------------|---------- > 2| name | Cost > 3|---------------------|---------- > 4| Chames bond| 1.750 > 5| Mel Gibson | 1.500 > 6| Madonna | 2.000 > > -------------------------------------------------- > > that is sheet 2 > > _| A | B > 1|---------------------|---------- > 2| name | Cost > 3|---------------------|---------- > 4| Hames bond | > 5| Mel Gibson | > 6| MEdonna | > 7| Rambo | > > > > --~--~---------~--~----~------------~-------~--~----~ Visit the blog to download Excel tutorials at http://www.excel-macros.blogspot.com To post to this group, send email to excel-macros@googlegroups.com For more options, visit this group at http://groups.google.com/group/excel-macros?hl=en Visit & Join Our Orkut Community at http://www.orkut.com/Community.aspx?cmm=22913620 To Learn VBA Macros Please visit http://www.vbamacros.blogspot.com To see the Daily Excel Tips, Go to: http://exceldailytip.blogspot.com If you find any spam message in the group, please send an email to Ayush @ jainayus...@gmail.com -~----------~----~----~----~------~----~------~--~---