Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How to make a macro which works same as hlookup?
Eg: I have some data in a different file and I need to get those to active sheet. if value in range a1:z1 matches a1.value in active sheet then it should get value from corresponing cloumn |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can try
Worksheetfunction.HLookup If this post helps click Yes --------------- Jacob Skaria "Kashyap" wrote: How to make a macro which works same as hlookup? Eg: I have some data in a different file and I need to get those to active sheet. if value in range a1:z1 matches a1.value in active sheet then it should get value from corresponing cloumn |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Adapt to suit
Sub hlookupa() MsgBox Application.hlookup(Range("b5"), Range("a1:z1"), 1, 0) End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "Kashyap" wrote in message ... How to make a macro which works same as hlookup? Eg: I have some data in a different file and I need to get those to active sheet. if value in range a1:z1 matches a1.value in active sheet then it should get value from corresponing cloumn |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
can I have the full code pls
|
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
set c = Rows(1).find(what:="abc",lookin:=xlvalues,lookat:= xlwhole)
then test fo c if c is nothing then msgbox("count not find abc") else msgbox("data found in column " & c.column) end if "Kashyap" wrote: How to make a macro which works same as hlookup? Eg: I have some data in a different file and I need to get those to active sheet. if value in range a1:z1 matches a1.value in active sheet then it should get value from corresponing cloumn |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
WorksheetFunction.hlookup("abc",Range("a1:z1"), 1, 0)
OR try with INDEX and MATCH Msgbox Application.Index(Range("A1:Z10"),1, _ Application.Match("abc", Range("A1:Z1"), 0)) If this post helps click Yes --------------- Jacob Skaria "Kashyap" wrote: can I have the full code pls |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm getting type mismatch error
|
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The range is having numbers or text?
Just post back with how the data is arranged and your current code.. If this post helps click Yes --------------- Jacob Skaria "Kashyap" wrote: I'm getting type mismatch error |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
ColA ColB ColC ColD ColE ColF
Calvin Amy Andy Calvin Danie Greg ABC GEF LMO GEF LMO GEF LMO IJK LMO LMO IJK IJK IJK In the above table, desiredoutput in ColA below Calvin LMO IJK formula used =HLOOKUP(A2,B2:F6,2) =HLOOKUP(A2,B2:F6,3) |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this
Application.HLookup(Range("A2"),Range("B2:F6"),2) OR Application.Index(Range("B2:F6"),2,Application.Mat ch(Range("A2"),Range("B2:F2"),0)) If this post helps click Yes --------------- Jacob Skaria "Kashyap" wrote: ColA ColB ColC ColD ColE ColF Calvin Amy Andy Calvin Danie Greg ABC GEF LMO GEF LMO GEF LMO IJK LMO LMO IJK IJK IJK In the above table, desiredoutput in ColA below Calvin LMO IJK formula used =HLOOKUP(A2,B2:F6,2) =HLOOKUP(A2,B2:F6,3) |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Using a worksheet function where you can use a VBA function is inefficient.
RowCount = 2 Person = Range("A" & RowCount) LastCol = Cells(RowCount, Columns.Count).End(xlToLeft).Column Set LookupRange = Range(Range("B" & RowCount), Cells(2, LastCol)) Set c = Rows(RowCount).Find(what:=Person, _ LookIn:=xlValues, lookat:=xlWhole) MsgBox (Person & " found at " & c.Address) Try this set c = "Jacob Skaria" wrote: Try this Application.HLookup(Range("A2"),Range("B2:F6"),2) OR Application.Index(Range("B2:F6"),2,Application.Mat ch(Range("A2"),Range("B2:F2"),0)) If this post helps click Yes --------------- Jacob Skaria "Kashyap" wrote: ColA ColB ColC ColD ColE ColF Calvin Amy Andy Calvin Danie Greg ABC GEF LMO GEF LMO GEF LMO IJK LMO LMO IJK IJK IJK In the above table, desiredoutput in ColA below Calvin LMO IJK formula used =HLOOKUP(A2,B2:F6,2) =HLOOKUP(A2,B2:F6,3) |
#13
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Compilation error
Expected:= |
#14
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do you have two postings mixed up? Expected isn't showing up anywhere in tis
posting. "Kashyap" wrote: Compilation error Expected:= |
#15
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
As Joel mentioned it may be inefficient. Since your original query was around
hookup try this one..from VBEimmediate window ?Application.HLookup(Range("A2"),Range("B2:F6"),2) If this post helps click Yes --------------- Jacob Skaria "Kashyap" wrote: Compilation error Expected:= |
#16
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Application is still performing a worksheet function. You code is no
different with or without the APPLICATION. "Jacob Skaria" wrote: As Joel mentioned it may be inefficient. Since your original query was around hookup try this one..from VBEimmediate window ?Application.HLookup(Range("A2"),Range("B2:F6"),2) If this post helps click Yes --------------- Jacob Skaria "Kashyap" wrote: Compilation error Expected:= |
#17
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Joel, I understand it is a worksheet function and I have not mentioned in my
previous post that it is an *** alternative *** VBA function . If this post helps click Yes --------------- Jacob Skaria "Joel" wrote: Application is still performing a worksheet function. You code is no different with or without the APPLICATION. "Jacob Skaria" wrote: As Joel mentioned it may be inefficient. Since your original query was around hookup try this one..from VBEimmediate window ?Application.HLookup(Range("A2"),Range("B2:F6"),2) If this post helps click Yes --------------- Jacob Skaria "Kashyap" wrote: Compilation error Expected:= |
#18
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Jacob,
I'm now getting compilation error Method not valid without suitable object "Jacob Skaria" wrote: As Joel mentioned it may be inefficient. Since your original query was around hookup try this one..from VBEimmediate window ?Application.HLookup(Range("A2"),Range("B2:F6"),2) If this post helps click Yes --------------- Jacob Skaria "Kashyap" wrote: Compilation error Expected:= |
#19
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
using below code, it says data found in 2 columns, but not able to paste data
to a different row "Joel" wrote: set c = Rows(1).find(what:="abc",lookin:=xlvalues,lookat:= xlwhole) then test fo c if c is nothing then msgbox("count not find abc") else msgbox("data found in column " & c.column) end if "Kashyap" wrote: How to make a macro which works same as hlookup? Eg: I have some data in a different file and I need to get those to active sheet. if value in range a1:z1 matches a1.value in active sheet then it should get value from corresponing cloumn |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
macro to lookup value and open tab based on lookup value | Excel Programming | |||
MACRO TO LOOKUP AND SUM | Excel Programming | |||
Lookup macro | Excel Discussion (Misc queries) | |||
Is it possible...lookup macro | Excel Programming | |||
Lookup macro? | Excel Programming |