ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   value in the 1st col of a range (https://www.excelbanter.com/excel-programming/302384-value-1st-col-range.html)

banavas[_10_]

value in the 1st col of a range
 
Dear Friends,

How can I check whether a value A exists in a range and specially i
the first column of the range?

I cannot figure out how does the rangeL.find() works.

msgbox(rangeL.Find(A)) breaks my code.

At last how can I pass a reference in a function?

ex.

VlookUp(ref, Range, 5, 0)

ref - the reference name of a value.

Thanks,


--
Message posted from http://www.ExcelForum.com


patrick molloy

value in the 1st col of a range
 
You need to study what objects are. Look in Help for find.

Where you use Find as a range object method, then it
returns a range opject. You cannot use msgbox for a range
object....you need to specify WHAT property you
want...and in this cas eyou'd use Value.

DIM Result As Range
SET Result = Source.Find(What)
' source is the range that you want to search in
IF NOT Result is Nothing THEN
' Result is a range object that has the value that you
' searched for
msgbox "Found in " & Result.Address
END IF


Passing reference to functions is one of the most basic
things to learn. Read HELP on Functions and procedures.

Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
Dear Friends,

How can I check whether a value A exists in a range and

specially in
the first column of the range?

I cannot figure out how does the rangeL.find() works.

msgbox(rangeL.Find(A)) breaks my code.

At last how can I pass a reference in a function?

ex.

VlookUp(ref, Range, 5, 0)

ref - the reference name of a value.

Thanks,
G


---
Message posted from http://www.ExcelForum.com/

.


Bob Phillips[_6_]

value in the 1st col of a range
 
Dim rng As Range
Dim oCell As Range

Set rng = Range("A1:H100")
Set oCell = rng.Columns(1).Find("a")
If Not oCell Is Nothing Then
MsgBox oCell.Address
End If

and

Dim ref
Dim rng As Range

Set rng = Range("A1:H100")
ref = "a"
MsgBox Application.VLookup(ref, rng, 5, 0)


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"banavas " wrote in message
...
Dear Friends,

How can I check whether a value A exists in a range and specially in
the first column of the range?

I cannot figure out how does the rangeL.find() works.

msgbox(rangeL.Find(A)) breaks my code.

At last how can I pass a reference in a function?

ex.

VlookUp(ref, Range, 5, 0)

ref - the reference name of a value.

Thanks,
G


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 05:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com