Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default vlookup lookup different column

No, I'm sorry, but I don't. Code doesn't "sit in [a] column". It's in a
module.

On 29 Oct 2004 21:45:52 -0700, (tango) wrote:

Dear Myrna,
I do not understand you. you see, if i follow my table column then i
will not get the value. originally the code is sitting in column B so
if in my vba i put B then i will not get anything. when i debug i
found out the code is sitting in column A. that is why in my vba i
refer to A and not B. do u see the point?
thanks alot





Because it's nearly impossible to figure out the layout from your
message --
where column A ends and column B begins. Where are the numbers? Column
C? You
don't mention column C.

On 29 Oct 2004 19:50:18 -0700,
(tango) wrote:

Dear All, may i know why the lookup value cell is referring to A and
not B? in my sheet the lookup value is in column B but why in my code
it refers to column A? i was given #ref when refer to B for lookup
value. so i did debug and found out it stores in column A. can have
your advice? thanks alot


column A column B
PROCUMENT DEPARTMENT COST 21000
CARBON STEEL 21100
CARBON STEEL - SHELL PLATE SA516-70N 21110
CARBON STEEL - HEADS 21120

Private Sub CommandButton1_Click()
Dim i As Long
Dim z As Range
Dim tableA As Range
Dim tableB As Range
Dim y

Set tableA = Range("A1:A100")
Set tableB = Sheet8.Range("$C$1:$D$2")

For i = 1 To Cells(Rows.Count, "A").End(xlUp).Row
X = tableA.Cells(i, "A").Value
Set z = tableA.Cells(i, "B")
If Cells(i, "A").Value = "" Then
' accumulate amount in TableB
Else
y = Application.VLookup("*" & X & "*", tableB, 2, False)
z.Value = y
End If
Next i

End Sub


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
Lookup looks to the prior column if zero appears in the lookup col kenbquik Excel Discussion (Misc queries) 2 March 12th 09 03:41 AM
=IF(AND(LOOKUP(F3,A21:A42)=F3,LOOKUP(B4,B21:B42)=B4),(VLOOKUP(B4,B RWD715 Excel Worksheet Functions 9 October 10th 08 10:11 PM
LookUp Function with Two Column Search Returning One Column Value insitedge Excel Worksheet Functions 8 March 3rd 08 05:59 AM
lookup text in one column, count in another column dmshurley Excel Worksheet Functions 1 August 17th 07 11:32 PM
Calculating totals in a column based on a lookup in another column Michael Wright via OfficeKB.com Excel Worksheet Functions 1 April 15th 05 09:52 AM


All times are GMT +1. The time now is 05:12 AM.

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"