J
jag
I am looking to create a VB fuction to use a stock reference in a cell
(A) from one workbook, to reference the correct column of information
corresponding to cell A and return the contents of the cell based its
3rd element and the 4th element.
Example:
Sheet1
A
B C
IBM
1/10 112.34
=ATMSTRIKE(A1,B1,C1) would return from the "B" column in Sheet2 "WIB
US 1/10 C110 Equity" by looking up 3 things 1) IBM,
2) the "1/10" as the 3rd element
3) and the smallest absolute value of the difference between
the number in the 4th element and number in C1
which is 112.34
Sheet2
A
B C
dell ibm msft
DLQ US 11 P22 Equity IBM US 6 C75 Equity MSQ US 6 C24
Equity
DLQ US 11 P23 Equity IBM US 6 C80 Equity MSQ US 6 C25
Equity
VPZ US 1 C10 Equity IBM US 7 P90 Equity MSQ US 7
C22.50 Equity
VPZ US 1 C15 Equity IBM US 10 P90 Equity MSQ US 7
C24 Equity
VPZ US 1 C17.50 Equity IBM US 1 P110 Equity MSQ US 1 C40
Equity
WDQ US 1/10 C17.50 Equity IBM US 1 P115 Equity MSQ US 1 C42.50
Equity
WDQ US 1/10 C20 Equity WIB US 1/10 C100 Equity WMF US 1/10
C35 Equity
WDQ US 1/10 C25 Equity WIB US 1/10 C110 Equity WMF US 1/10
C37.50 Equity
WIB US 1/10 C120 Equity WMF US 1/10
C40 Equity
WIB US 1/10 C125 Equity
I would assume you would use multiple functions to create one such as:
Function ExtractElement (txt,n,Seperator)
Dim AllElements As Variant
AllElements = Split(txt,Seperator)
ExtractElement = AllElements(n-1)
End Function
and also Match and Loops, just having hard time putting it all
together
Thanks in advance,
JAG
(A) from one workbook, to reference the correct column of information
corresponding to cell A and return the contents of the cell based its
3rd element and the 4th element.
Example:
Sheet1
A
B C
IBM
1/10 112.34
=ATMSTRIKE(A1,B1,C1) would return from the "B" column in Sheet2 "WIB
US 1/10 C110 Equity" by looking up 3 things 1) IBM,
2) the "1/10" as the 3rd element
3) and the smallest absolute value of the difference between
the number in the 4th element and number in C1
which is 112.34
Sheet2
A
B C
dell ibm msft
DLQ US 11 P22 Equity IBM US 6 C75 Equity MSQ US 6 C24
Equity
DLQ US 11 P23 Equity IBM US 6 C80 Equity MSQ US 6 C25
Equity
VPZ US 1 C10 Equity IBM US 7 P90 Equity MSQ US 7
C22.50 Equity
VPZ US 1 C15 Equity IBM US 10 P90 Equity MSQ US 7
C24 Equity
VPZ US 1 C17.50 Equity IBM US 1 P110 Equity MSQ US 1 C40
Equity
WDQ US 1/10 C17.50 Equity IBM US 1 P115 Equity MSQ US 1 C42.50
Equity
WDQ US 1/10 C20 Equity WIB US 1/10 C100 Equity WMF US 1/10
C35 Equity
WDQ US 1/10 C25 Equity WIB US 1/10 C110 Equity WMF US 1/10
C37.50 Equity
WIB US 1/10 C120 Equity WMF US 1/10
C40 Equity
WIB US 1/10 C125 Equity
I would assume you would use multiple functions to create one such as:
Function ExtractElement (txt,n,Seperator)
Dim AllElements As Variant
AllElements = Split(txt,Seperator)
ExtractElement = AllElements(n-1)
End Function
and also Match and Loops, just having hard time putting it all
together
Thanks in advance,
JAG