+ Reply to Thread
Results 1 to 6 of 6

Compare one cells from sheet 2 and paste the value in front of the cell

Hybrid View

  1. #1
    Registered User
    Join Date
    12-15-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    13

    Compare one cells from sheet 2 and paste the value in front of the cell

    Hello,
    I m new to excel with VB coding
    Please help me
    I have the table as follows:-

    Shee1 1
    A B
    1 apple 10
    2 mango 100
    3 banana 1000


    now if i go to sheet 2 and type in

    A1 "Banana" then automatically there would be "1000" in cell B1

    sheet 2
    A B
    1 Banana 1000
    2 apple 10
    3


    suggest me any formula in vba

    thanks

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Compare one cells from sheet 2 and paste the value in front of the cell

    Hi jeevan123,

    Welcome to the forum!!

    Try this formula in cell B1 of Sheet2 and then copied as required:

    =VLOOKUP(A1,Sheet1!A:B,2,FALSE)

    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Registered User
    Join Date
    12-15-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Compare one cells from sheet 2 and paste the value in front of the cell

    thanks for your reply

    Plz see the attatchment
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    12-15-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Compare one cells from sheet 2 and paste the value in front of the cell

    Hello Mr. Robert

    I have tried again and my problem is solved now.

    thanks,

    Ms. Jeevan

  5. #5
    Registered User
    Join Date
    12-15-2012
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Compare one cells from sheet 2 and paste the value in front of the cell

    Hello Trebor76

    I have tried again and my problem is solved now.

    thanks,

    Ms. Jeevan

  6. #6
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565

    Re: Compare one cells from sheet 2 and paste the value in front of the cell

    Try this event macro on Sheet1:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)
    
        'Written by Trebor76
        'Visit my website www.excelguru.net.au
    
        If Target.Column = 1 Then
            If (IsError(Evaluate("VLOOKUP(""" & Target.Value & """,Sheet2!A:B,2,FALSE)"))) = False Then
                Application.EnableEvents = False
                    Target.Offset(0, 1).Value = Evaluate("VLOOKUP(""" & Target.Value & """,Sheet2!A:B,2,FALSE)")
                Application.EnableEvents = True
            End If
        End If
    
    End Sub
    Robert

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1