+ Reply to Thread
Results 1 to 6 of 6

copy vlookup value using macro

Hybrid View

  1. #1
    Registered User
    Join Date
    02-05-2014
    Location
    Malang
    MS-Off Ver
    Excel 2007
    Posts
    33

    copy vlookup value using macro

    hi everyone
    i want get value from vlookup and copy it into another sheet
    every time i run the code it show no error but value is blank
    this is my code

    Private Sub CommandButton1_Click()

    Application.ScreenUpdating = False
    Dim name, v, n As String
    Dim l, m As Range

    name = Sheets("sheet3").Range("b1").Value
    Set m = Range("a1:b4")
    v = Application.WorksheetFunction.VLookup(name, m, 2, False)
    n = Worksheets("sheet3").Range("b1").Value
    Set l = Worksheets("sheet3").Range("a1")

    If n = v Then
    v.Value.Copy destination:=l

    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    Else
    Exit Sub
    End If
    End Sub

    Thank you

    Unik's

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: copy vlookup value using macro

    Try this...

    I.Value = v
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Registered User
    Join Date
    02-05-2014
    Location
    Malang
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: copy vlookup value using macro

    it still didn't work

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: copy vlookup value using macro

    Maybe?

    Sub uniks()
    Application.ScreenUpdating = False
    Dim name, v, n As String
    Dim l, m As Range
    
    name = Sheets("sheet3").Range("b1").Value
    Set m = Range("a1:b4")
    v = Application.WorksheetFunction.VLookup(name, m, 2, False)
    n = Worksheets("sheet3").Range("b1").Value
    Set l = Worksheets("sheet3").Range("a1")
    
    If n = v Then
    v.Copy
    l.PasteSpecial xlPasteValues
    
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    Else
    Exit Sub
    End If
    End Sub

  5. #5
    Registered User
    Join Date
    02-05-2014
    Location
    Malang
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: copy vlookup value using macro

    it didn't work either

  6. #6
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: copy vlookup value using macro

    In this case it would be helpful if you upload a sample file along with your code to show your desired output.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help with VLOOKUP and Copy & Paste Macro
    By slny06 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-19-2013, 09:03 AM
  2. VBA Macro to Copy and Paste a row Like a VLOOKUP
    By arlecchino in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-25-2012, 05:10 AM
  3. [SOLVED] Vlookup with copy and paste macro
    By kasperblue in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-04-2012, 05:27 PM
  4. [SOLVED] vlookup reference replaced with #REF! after copy paste macro ran
    By dylaughin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-10-2012, 11:21 AM
  5. Vlookup Macro for copy paste of rows
    By sajeel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-15-2010, 11:33 AM

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