+ Reply to Thread
Results 1 to 3 of 3

vlookup in reverse

  1. #1
    Newbie
    Guest

    vlookup in reverse

    Hi,

    I need to change the value of cells found via application.vlookup in vba

    Is there a simple way to do this from a userform?

    Thanx

  2. #2
    Tom Ogilvy
    Guest

    RE: vlookup in reverse

    Assume you Vlookup looks as A1:F10 of the activesheet using the value in
    Textbox1. Then to alter the cell in column A that matches the value in
    Textbox1:

    Dim rng as Range, rng1 as Range, res as Variant
    set rng = Range("A1:A10")
    res = Application.Match(Userform1.Textbox1.Text,rng,1)
    if not iserror(res) then
    set rng1 = rng(res)
    rng1.clearcontents
    end if

    to alter the value in column E (column 5) of that row
    Dim rng as Range, rng1 as Range, res as Variant
    set rng = Range("A1:A10")
    res = Application.Match(Userform1.Textbox1.Text,rng,1)
    if not iserror(res) then
    set rng1 = rng(res,5)
    rng1.clearcontents
    end if

    --
    Regards,
    Tom Ogilvy

    "Newbie" wrote:

    > Hi,
    >
    > I need to change the value of cells found via application.vlookup in vba
    >
    > Is there a simple way to do this from a userform?
    >
    > Thanx


  3. #3
    Dave Peterson
    Guest

    Re: vlookup in reverse

    Option Explicit
    sub testme()

    dim myRng as range
    dim res as variant
    dim myVal as variant

    with worksheets("Sheet999")
    set myrng = .range("A1",.cells(.rows.count,"A").end(xlup))
    myVal = "something to match"
    res = application.match(myval,myrng,0)
    if iserror(res) then
    'msgbox not found
    else
    myrng(res).offset(0,5).value = "new value"
    end if
    end with
    end sub

    the .offset(0,5) says to go 5 columns to the left of the column to be checked.

    Newbie wrote:
    >
    > Hi,
    >
    > I need to change the value of cells found via application.vlookup in vba
    >
    > Is there a simple way to do this from a userform?
    >
    > Thanx


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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