Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default VBA formula building

hello,

i try to write a function corresponding to index and match
functions used in excel spreadsheets..

i have sth like this:

Function FindID(c As Variant, x As Integer)

'c - file (ie. [file1.xls]
'x - arkusz (ie. 4

FindID = "=INDEX('" & c & x & "'!R8C3:R8C154,1,MATCH(RC3,'" & c & x & "'!R15C3:R15C154,0))"

End Function

is it possible to build forumula in such a way?

best
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA formula building

Function FindID(c As Variant, x As Integer)

'c - file (ie. [file1.xls]
'x - arkusz (ie. 4

s = "=INDEX('" & c & x & "'!R8C3:R8C154,1,MATCH(RC3,'" & c & x &
"'!R15C3:R15C154,0))"
FindID = Evaluate(s)
End Function

--
Regards,
Tom Ogilvy


"pm" wrote in message ...
hello,

i try to write a function corresponding to index and match
functions used in excel spreadsheets..

i have sth like this:

Function FindID(c As Variant, x As Integer)

'c - file (ie. [file1.xls]
'x - arkusz (ie. 4

FindID = "=INDEX('" & c & x & "'!R8C3:R8C154,1,MATCH(RC3,'" & c & x &

"'!R15C3:R15C154,0))"

End Function

is it possible to build forumula in such a way?

best



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default VBA formula building

Tom Ogilvy wrote:

Function FindID(c As Variant, x As Integer)

'c - file (ie. [file1.xls]
'x - arkusz (ie. 4

s = "=INDEX('" & c & x & "'!R8C3:R8C154,1,MATCH(RC3,'" & c & x & "'!R15C3:R15C154,0))"
FindID = Evaluate(s)
End Function


it doesn't work :/
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA formula building

I had to change x to String so I could pass it a sheet name, but once I did
that and put my workbook in R1C1 mode and entered data in the appropriate
places, it worked for me

=findid("[aa_test.xls]","Sheet1")

--
Regards,
Tom Ogilvy


"pm" wrote in message ...
Tom Ogilvy wrote:

Function FindID(c As Variant, x As Integer)

'c - file (ie. [file1.xls]
'x - arkusz (ie. 4

s = "=INDEX('" & c & x & "'!R8C3:R8C154,1,MATCH(RC3,'" & c & x &

"'!R15C3:R15C154,0))"
FindID = Evaluate(s)
End Function


it doesn't work :/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default VBA formula building

Tom Ogilvy wrote:

I had to change x to String so I could pass it a sheet name, but once I did
that and put my workbook in R1C1 mode and entered data in the appropriate
places, it worked for me

=findid("[aa_test.xls]","Sheet1")


now, function looks like this:

Function FindID(c As Variant, x As String)
'c - file
'x - sheet

s = "=INDEX('" & c & x & "'!R8C3:R8C154,1,MATCH(RC3,'" & c & x & "'!R15C3:R15C154,0))"
FindID = Evaluate(s)

End Function

and formula returns #ARG!

arguments c and x are results of formulas in other cells

i use this function in this way:

=findid(C5;B3)

value in C5 (c) is [names_en.xls]
value in B3 (x) is 4


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA formula building

Unless your sheet is named 4, then there is no way that will work. If you
want to refer to the 4th sheet in the tab order, then your function would
require more work:

Function FindID(c As Variant, x1 As Integer)

'c - file (ie. [file1.xls]
'x - arkusz (ie. 4

x = Worksheets(x1).Name

s = "=INDEX('" & c & x & "'!R8C3:R8C154,1,MATCH(RC3,'" & c & x &
"'!R15C3:R15C154,0))"

FindID = Evaluate(s)
End Function



--
Regards,
Tom Ogilvy


"pm" wrote in message ...
Tom Ogilvy wrote:

I had to change x to String so I could pass it a sheet name, but once I

did
that and put my workbook in R1C1 mode and entered data in the

appropriate
places, it worked for me

=findid("[aa_test.xls]","Sheet1")


now, function looks like this:

Function FindID(c As Variant, x As String)
'c - file
'x - sheet

s = "=INDEX('" & c & x & "'!R8C3:R8C154,1,MATCH(RC3,'" & c & x &

"'!R15C3:R15C154,0))"
FindID = Evaluate(s)

End Function

and formula returns #ARG!

arguments c and x are results of formulas in other cells

i use this function in this way:

=findid(C5;B3)

value in C5 (c) is [names_en.xls]
value in B3 (x) is 4



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
Loose formula/value (when building graphs) PvZ Excel Worksheet Functions 3 June 2nd 10 12:24 PM
Formula Building in Excel 2007 Mike H. Excel Discussion (Misc queries) 2 June 24th 09 01:46 PM
When building formula in excel, it would be very useful to have t. [email protected] Excel Programming 1 October 20th 04 12:07 PM
When building formula in excel, it would be very useful to have t. [email protected] Excel Programming 0 October 20th 04 11:09 AM
Building a Named Range in a formula with VBA John[_80_] Excel Programming 1 July 7th 04 03:06 PM


All times are GMT +1. The time now is 04:13 PM.

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"