Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default index function in vba

Hi,

I have a problem finding data in a matrix.

I have a cell that is filled with stuff like "18 - 20"
I have a matrix on another sheet in the range
worksheets("staffels").range("A4:CS53")
Now i would like to do the following:

take the first two items ("18") of the cell minus the number 14 and look
this ip in column 1 of the matrix and then i need the result from column
number -58 + var1 + var2

Does anybody have a hint how to do this in VBA ?
Thanks,
Pierre


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default index function in vba

Dmi var1 as Long, Var2 as Long
Dim rng as Range, res as Variant
Dim rw as Long, result as Variant
var1 = ?
Var2 = ?
set rng = worksheets("Data").Range("A4:A53")
res = Application.Match(clng(left(activecell,2)),rng,0)
if not iserror(res) then
rw = rng(res).row
result = cells(rw,-58+var1+var2)
msgbox result
End if

Assumes column 1 contains numbers stored as numbers

--
Regards,
Tom Ogilvy

"Jean-Pierre" wrote in message
...
Hi,

I have a problem finding data in a matrix.

I have a cell that is filled with stuff like "18 - 20"
I have a matrix on another sheet in the range
worksheets("staffels").range("A4:CS53")
Now i would like to do the following:

take the first two items ("18") of the cell minus the number 14 and look
this ip in column 1 of the matrix and then i need the result from column
number -58 + var1 + var2

Does anybody have a hint how to do this in VBA ?
Thanks,
Pierre




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default index function in vba

Sub GetVal()
Dim var1 As Long
Dim Var2 As Long
Dim rng As Range
Dim cell As Range
Dim res As Variant
Dim rw As Long, result As Variant
var1 = 1
Var2 = 2
Set rng = Worksheets("Data").Range("A4:CS53")
res = InStr(1, ActiveCell.Value, " -")
If res 0 Then
Set cell = rng.Find(CLng(Left(ActiveCell, res - 1)))
If Not cel Is Nothing Then
If cell.Column (58 - var1 - Var2) Then
result = Cells(cell.Row, cell.Column - 58 + var1 + Var2)
MsgBox result
End If
End If
End If
End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jean-Pierre" wrote in message
...
Hi,

I have a problem finding data in a matrix.

I have a cell that is filled with stuff like "18 - 20"
I have a matrix on another sheet in the range
worksheets("staffels").range("A4:CS53")
Now i would like to do the following:

take the first two items ("18") of the cell minus the number 14 and look
this ip in column 1 of the matrix and then i need the result from column
number -58 + var1 + var2

Does anybody have a hint how to do this in VBA ?
Thanks,
Pierre




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
Using INDIRECT Function and INDEX Function ChristopherG Excel Discussion (Misc queries) 1 June 10th 09 04:07 PM
INDEX function John Case Excel Worksheet Functions 3 August 21st 08 07:13 AM
INDEX FUNCTION Gulfman100 New Users to Excel 6 April 11th 08 12:51 PM
Index Function/Match Function M Moore Excel Discussion (Misc queries) 3 September 3rd 06 11:49 AM
Emulate Index/Match combo function w/ VBA custom function Spencer Hutton Excel Worksheet Functions 2 May 2nd 05 05:26 PM


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