Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
vlookup in reverse AJSloss Excel Discussion (Misc queries) 4 July 18th 09 04:20 PM
Any Way to Use Vlookup in Reverse? opieandy Excel Discussion (Misc queries) 3 July 5th 09 07:41 AM
REVERSE VLOOKUP FARAZ QURESHI Excel Discussion (Misc queries) 3 July 26th 08 08:12 AM
Reverse VLOOKUP Matt Excel Discussion (Misc queries) 1 January 28th 08 10:34 PM
Reverse VlookUp Matt Excel Discussion (Misc queries) 1 January 28th 08 09:55 PM


All times are GMT +1. The time now is 02:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"