Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default Index function in VBA - on Multiple cells

Struggling here and maybe being a bit thick, however had a look at Tom
Ogilvys resonse to a similar question on the 16 August 2006, tried to use the
same principals to no avail.

I have a number of PC's with large number of files that I am trying to tidy
up. I have created worksheets for all the files named on the IP Address. I
wish to have an index function that returns information dependant on 3 fields
in the main page.

I am trying to use Index and Match functions to obtain the information.
The code works fine with the formula in the cell, however with a large
number of PC's I would need to run the machine overnight !

The function I have tried is below

Function GetFileVersion(strFilePath As String, strFileName As String,
strFileType As String, strPCIP As String)

Dim ans As Variant

ans = Evaluate("INDEX('" & strPCIP & "'!$K$1:$K$5000,(MATCH((strFilePath &
strFileName & strFileType), ('" & strPCIP & "'!$A$1:$A$5000&'" & strPCIP &
"'!$B$1:$B$5000&'" & strPCIP & "'!$D$1:$D$5000),0))")

If Not IsError(ans) Then
MsgBox ans
Else
MsgBox "Not found"
End If

GetFileVersion = ans

End Function

Any help or pointers would be greatly appreciated

Regards


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Index function in VBA - on Multiple cells

Try this

Function GetFileVersion(strFilePath As String, _
strFileName As String, _
strFileType As String, _
strPCIP As String)
Dim ans As Variant
Dim sFormula As String

sFormula = "INDEX('" & strPCIP & "'!$K$1:$K$5000,(MATCH((""" & _
strFilePath & """&""" & strFileName & """&""" & strFileType
& _
"),('" & strPCIP & "'!$A$1:$A$5000&'" & strPCIP & _
"'!$B$1:$B$5000&'" & strPCIP & "'!$D$1:$D$5000),0))"

ans = Evaluate(sFormula)

If Not IsError(ans) Then
GetFileVersion = ans
Else
GetFileVersion = "Not found"
End If

End Function



--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Alan" wrote in message
...
Struggling here and maybe being a bit thick, however had a look at Tom
Ogilvys resonse to a similar question on the 16 August 2006, tried to use

the
same principals to no avail.

I have a number of PC's with large number of files that I am trying to

tidy
up. I have created worksheets for all the files named on the IP Address. I
wish to have an index function that returns information dependant on 3

fields
in the main page.

I am trying to use Index and Match functions to obtain the information.
The code works fine with the formula in the cell, however with a large
number of PC's I would need to run the machine overnight !

The function I have tried is below

Function GetFileVersion(strFilePath As String, strFileName As String,
strFileType As String, strPCIP As String)

Dim ans As Variant

ans = Evaluate("INDEX('" & strPCIP & "'!$K$1:$K$5000,(MATCH((strFilePath &
strFileName & strFileType), ('" & strPCIP & "'!$A$1:$A$5000&'" & strPCIP &
"'!$B$1:$B$5000&'" & strPCIP & "'!$D$1:$D$5000),0))")

If Not IsError(ans) Then
MsgBox ans
Else
MsgBox "Not found"
End If

GetFileVersion = ans

End Function

Any help or pointers would be greatly appreciated

Regards




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default Index function in VBA - on Multiple cells

Bob

Again many thanks for your response ... however seems i get a negative
result although I know the file is there ...

The code within the cell is

=INDEX('###.##.#.###'!$K$1:$K$5000,MATCH(B7&C11&D1 1,'###.##.#.###'!$A$1:$A$5000&'###.##.#.###'!$B$1: $B$5000&'###.##.#.###'!$D$1:$D$5000,0))

And I get the right info

Any Ideas ???

Thanks

"Bob Phillips" wrote:

Try this

Function GetFileVersion(strFilePath As String, _
strFileName As String, _
strFileType As String, _
strPCIP As String)
Dim ans As Variant
Dim sFormula As String

sFormula = "INDEX('" & strPCIP & "'!$K$1:$K$5000,(MATCH((""" & _
strFilePath & """&""" & strFileName & """&""" & strFileType
& _
"),('" & strPCIP & "'!$A$1:$A$5000&'" & strPCIP & _
"'!$B$1:$B$5000&'" & strPCIP & "'!$D$1:$D$5000),0))"

ans = Evaluate(sFormula)

If Not IsError(ans) Then
GetFileVersion = ans
Else
GetFileVersion = "Not found"
End If

End Function



--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Alan" wrote in message
...
Struggling here and maybe being a bit thick, however had a look at Tom
Ogilvys resonse to a similar question on the 16 August 2006, tried to use

the
same principals to no avail.

I have a number of PC's with large number of files that I am trying to

tidy
up. I have created worksheets for all the files named on the IP Address. I
wish to have an index function that returns information dependant on 3

fields
in the main page.

I am trying to use Index and Match functions to obtain the information.
The code works fine with the formula in the cell, however with a large
number of PC's I would need to run the machine overnight !

The function I have tried is below

Function GetFileVersion(strFilePath As String, strFileName As String,
strFileType As String, strPCIP As String)

Dim ans As Variant

ans = Evaluate("INDEX('" & strPCIP & "'!$K$1:$K$5000,(MATCH((strFilePath &
strFileName & strFileType), ('" & strPCIP & "'!$A$1:$A$5000&'" & strPCIP &
"'!$B$1:$B$5000&'" & strPCIP & "'!$D$1:$D$5000),0))")

If Not IsError(ans) Then
MsgBox ans
Else
MsgBox "Not found"
End If

GetFileVersion = ans

End Function

Any help or pointers would be greatly appreciated

Regards





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default Index function in VBA - on Multiple cells

Bob

Cancel ... my typing is not what it shoulf be ... syntax and brackets
Once again very much obliged for your help

Regards

"Alan" wrote:

Bob

Again many thanks for your response ... however seems i get a negative
result although I know the file is there ...

The code within the cell is

=INDEX('###.##.#.###'!$K$1:$K$5000,MATCH(B7&C11&D1 1,'###.##.#.###'!$A$1:$A$5000&'###.##.#.###'!$B$1: $B$5000&'###.##.#.###'!$D$1:$D$5000,0))

And I get the right info

Any Ideas ???

Thanks

"Bob Phillips" wrote:

Try this

Function GetFileVersion(strFilePath As String, _
strFileName As String, _
strFileType As String, _
strPCIP As String)
Dim ans As Variant
Dim sFormula As String

sFormula = "INDEX('" & strPCIP & "'!$K$1:$K$5000,(MATCH((""" & _
strFilePath & """&""" & strFileName & """&""" & strFileType
& _
"),('" & strPCIP & "'!$A$1:$A$5000&'" & strPCIP & _
"'!$B$1:$B$5000&'" & strPCIP & "'!$D$1:$D$5000),0))"

ans = Evaluate(sFormula)

If Not IsError(ans) Then
GetFileVersion = ans
Else
GetFileVersion = "Not found"
End If

End Function



--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Alan" wrote in message
...
Struggling here and maybe being a bit thick, however had a look at Tom
Ogilvys resonse to a similar question on the 16 August 2006, tried to use

the
same principals to no avail.

I have a number of PC's with large number of files that I am trying to

tidy
up. I have created worksheets for all the files named on the IP Address. I
wish to have an index function that returns information dependant on 3

fields
in the main page.

I am trying to use Index and Match functions to obtain the information.
The code works fine with the formula in the cell, however with a large
number of PC's I would need to run the machine overnight !

The function I have tried is below

Function GetFileVersion(strFilePath As String, strFileName As String,
strFileType As String, strPCIP As String)

Dim ans As Variant

ans = Evaluate("INDEX('" & strPCIP & "'!$K$1:$K$5000,(MATCH((strFilePath &
strFileName & strFileType), ('" & strPCIP & "'!$A$1:$A$5000&'" & strPCIP &
"'!$B$1:$B$5000&'" & strPCIP & "'!$D$1:$D$5000),0))")

If Not IsError(ans) Then
MsgBox ans
Else
MsgBox "Not found"
End If

GetFileVersion = ans

End Function

Any help or pointers would be greatly appreciated

Regards





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
INDEX function multiple columns & rows jasebeds Excel Worksheet Functions 2 August 27th 06 05:41 PM
Index function using multiple values in one cell [email protected] Excel Worksheet Functions 2 May 11th 06 08:14 PM
Index multiple cells xxxMarkxxx Excel Worksheet Functions 1 December 6th 05 09:23 PM
Index Match function for multiple linked variables Bob Excel Worksheet Functions 13 November 23rd 05 12:56 AM
Index Match function for multiple linked variables Bob Excel Worksheet Functions 0 November 22nd 05 02:12 AM


All times are GMT +1. The time now is 08:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"