#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Offset


Hi Freinds,

I have a Table with 2 Fields

A B
1000 ABC
2000 DEF
3000 GHI
4000 JKL


I want to Find "GHI" in col B and if found then shows the corresponding
value of Col "A" i,e 3000.

In simple the Formula is

@offset(b1,match("GHI,b1:b4,0)-1,-1)

I neet the code in VBA-Excel

Thanks

Syed Haider Ali


--
Syed Haider Ali
------------------------------------------------------------------------
Syed Haider Ali's Profile: http://www.excelforum.com/member.php...o&userid=21994
View this thread: http://www.excelforum.com/showthread...hreadid=400053

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default Offset

This code assumes that you only want to find the first instacne of GHI but it
is easily modified to find all of the instances if you need...

Sub test()
Call FindStuff("GHI")
End Sub

Public Sub FindStuff(ByVal ThingToFind As Variant)
Dim wks As Worksheet
Dim rngToSearch As Range
Dim rngCurrent As Range

Set wks = ActiveSheet
Set rngToSearch = wks.Columns(2)
Set rngCurrent = rngToSearch.Find(ThingToFind)
If rngCurrent Is Nothing Then
MsgBox ThingToFind & " was not found."
Else
MsgBox rngCurrent.Offset(0, -1).Value
End If

End Sub

--
HTH...

Jim Thomlinson


"Syed Haider Ali" wrote:


Hi Freinds,

I have a Table with 2 Fields

A B
1000 ABC
2000 DEF
3000 GHI
4000 JKL


I want to Find "GHI" in col B and if found then shows the corresponding
value of Col "A" i,e 3000.

In simple the Formula is

@offset(b1,match("GHI,b1:b4,0)-1,-1)

I neet the code in VBA-Excel

Thanks

Syed Haider Ali


--
Syed Haider Ali
------------------------------------------------------------------------
Syed Haider Ali's Profile: http://www.excelforum.com/member.php...o&userid=21994
View this thread: http://www.excelforum.com/showthread...hreadid=400053


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Offset

One way:

Dim rFound As Range
Set rFound = Range("B:B").Find( _
What:="GHI", _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=False)
If Not rFound Is Nothing Then _
MsgBox rFound.Offset(0, -1)

BTW - your XL formula would be a bit more efficient as

=INDEX(A1:A4,MATCH("GHI",B1:B4,FALSE))



In article
<Syed.Haider.Ali.1uj46h_1125324326.0393@excelfor um-nospam.com,
Syed Haider Ali
<Syed.Haider.Ali.1uj46h_1125324326.0393@excelfor um-nospam.com wrote:

Hi Freinds,

I have a Table with 2 Fields

A B
1000 ABC
2000 DEF
3000 GHI
4000 JKL


I want to Find "GHI" in col B and if found then shows the corresponding
value of Col "A" i,e 3000.

In simple the Formula is

@offset(b1,match("GHI,b1:b4,0)-1,-1)

I neet the code in VBA-Excel

Thanks

Syed Haider Ali

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
OFFSET Jose Mourinho Excel Worksheet Functions 1 December 23rd 09 01:26 PM
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul RyGuy Excel Worksheet Functions 2 September 28th 07 10:54 PM
Offset Help Hunter Excel Worksheet Functions 5 January 26th 07 02:21 PM
OFFSET PLEASE HELP! HERNAN Excel Discussion (Misc queries) 6 October 27th 06 10:17 PM
Problem with Range.Cells.Offset and Range.Cells( row + offset, column) [email protected] Excel Programming 2 August 22nd 05 05:25 AM


All times are GMT +1. The time now is 04:36 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"