Closed Thread
Results 1 to 22 of 22

VLOOKUP with macro

  1. #1
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    VLOOKUP with macro

    Hello everybody.
    In the attached workbook there is a formula cerca.vert

    Please Login or Register  to view this content.
    is it possible to turn it into a macro at each new insertion in the range L7:L31 ?
    Thank you.
    xam
    Attached Files Attached Files

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,448

    Re: VLOOKUP with macro

    If you mean extending the formula when you insert a row, no macro needed
    Make your range an Excel Table, and any added row will create the formula automatically

  3. #3
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    Re: VLOOKUP with macro

    Hi peppe le mokko
    I don't mean what you say.
    I ask to translate the formula into a macro at each insertion

  4. #4
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    Re: VLOOKUP with macro

    Hi,
    i made this macro but it doesn't work
    Please Login or Register  to view this content.
    it must work in the range L7:L31 and return the value in B7:B31.
    xam
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VLOOKUP with macro

    Do you mean like this?
    Please Login or Register  to view this content.
    Last edited by jindon; 10-24-2020 at 09:07 AM. Reason: Fixed a typo

  6. #6
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    Re: VLOOKUP with macro

    In L7:L31 there is nothing
    Attached Files Attached Files

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VLOOKUP with macro

    It uses Change event, like your code, so it only works when you change any cell in L7:L31 (got typo in my code, L2:L31)

    Enter any thing in blank cell, so that you will see.

  8. #8
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    Re: VLOOKUP with macro

    I'm probably doing something wrong.
    I did as you say (I hope) but it doesn't change.
    Write in B7: B31 the result in cells L7: L31
    Attached Files Attached Files

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VLOOKUP with macro

    Try
    1) Clear L7:L31 in S1 sheet
    2) Enter 123460 in any cell in L7:L31
    3) You should see the result in Col.B in S1 sheet.

    Above is working here.

  10. #10
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    Re: VLOOKUP with macro

    tried several times in B7: B31 nothing comes out

  11. #11
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VLOOKUP with macro

    No result, no error?

    Don't know why...

    try change to
    Please Login or Register  to view this content.
    Last edited by jindon; 10-24-2020 at 09:48 AM.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VLOOKUP with macro

    I wonder if Events are disabled.
    Try the attached.
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    Re: VLOOKUP with macro

    I don't know nothing comes out of me

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VLOOKUP with macro

    See my previous post.

  15. #15
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    Re: VLOOKUP with macro

    tried # 12 doesn't work on me

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VLOOKUP with macro

    I can not test this.
    Not sure if you need to change semi-column ";" to a comma "," in the formula.
    Please Login or Register  to view this content.

  17. #17
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    Re: VLOOKUP with macro

    I shut down and restarted the computer, now everything works.
    Thanks jindon

  18. #18
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VLOOKUP with macro

    Yeah, it should...

    Please don't forget to mark the thread as [SOLVED].

  19. #19
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    Re: VLOOKUP with macro

    I moved the data_base to test and changed here

    r(, -9) = WorksheetFunction.IfError(Application.VLookup(r, _
    Sheets("data_base").Columns("D:I"), 5, False), "v.n.d")

    but non work, where am i wrong?
    Attached Files Attached Files

  20. #20
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: VLOOKUP with macro

    5 should be 6
    Please Login or Register  to view this content.

  21. #21
    Forum Contributor
    Join Date
    08-27-2019
    Location
    europa
    MS-Off Ver
    excel 2007
    Posts
    456

    Re: VLOOKUP with macro

    Thanks you jindon

  22. #22
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,987

    Re: VLOOKUP with macro

    Administrative Note:

    Unfortunately, this is a duplicate thread, and you are allowed only ONE thread per issue here.

    Please see Forum Rule #5 about thread duplication.

    I am closing this thread, but you may continue here in the original thread: https://www.excelforum.com/excel-pro...e-vlookup.html
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] IF(ISERROR(VLOOKUP,"",VLOOKUP) in macro produces run-time error 1004
    By doleenovodno in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-01-2018, 09:00 AM
  2. Replies: 3
    Last Post: 07-10-2014, 10:56 AM
  3. [SOLVED] Macro- adding Vlookup to a macro
    By TERRI LEE in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 05-06-2013, 02:28 AM
  4. [SOLVED] Adapt A Sumif Macro to A Vlookup Macro
    By timbo1957 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-30-2012, 06:22 PM
  5. Complex Vlookup/ VBA function or Macro Needed For "if contains text then vlookup"
    By alfykunable in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-09-2012, 03:48 AM
  6. Applying Vlookup using a Macro(Vlookup+Macro) in Excel 2007
    By Sumku in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-03-2009, 08:58 PM
  7. Replies: 1
    Last Post: 02-26-2005, 02:06 PM

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