Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi. I have another question. I am trying to post this: OFFSET($A$4,MATCH
(C21,$A$5:$A$17,0),MATCH(D21,$B$4:$M$4,0)) into a vba program but can't get it to work. I understand that the $$ are not recognized in vba and also, how would I go about putting this equation into a sub procedure? I tried calling it price = offset(....... Also, this is a set range that will not move. How can the program be structured to where $a$4 will always be the range or array's starting point? I have stock symbols in a row with dates down the left column. Stock prices fill the range. thansk. chris -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200707/1 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() not sure what you want. this enters the formula in A1 Range("A1").Formula = "= OFFSET($A$4,MATCH(C21,$A$5:$A$17,0),MATCH(D21,$B$4 :$M$4,0))" -- Gary "ctallen23 via OfficeKB.com" <u36101@uwe wrote in message news:75bab958e9687@uwe... Hi. I have another question. I am trying to post this: OFFSET($A$4,MATCH (C21,$A$5:$A$17,0),MATCH(D21,$B$4:$M$4,0)) into a vba program but can't get it to work. I understand that the $$ are not recognized in vba and also, how would I go about putting this equation into a sub procedure? I tried calling it price = offset(....... Also, this is a set range that will not move. How can the program be structured to where $a$4 will always be the range or array's starting point? I have stock symbols in a row with dates down the left column. Stock prices fill the range. thansk. chris -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200707/1 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I haven't tested this code, but it should work. Because you hard coded
location with $ they will never change. So you can put these locations directly into the function. =getstockrange(c21,D21) Function getstockrange(findparm1 As range, _ findparm2 As range) As Range Set c1 = Range("A5:A17"). _ Find(findparm1, LookIn:=xlValues) Set c2 = Range("B4:M4"). _ Find(findparm2, LookIn:=xlValues) Set getstockrange = Range(Range("A4"), _ Cells(c1.Row, c2.Column)) End Function ---------------------------------------------------------------------------- another way is the following =getstockrange($A$4,c21,$A$5:$A$17,D21,$B$4:$M$4) Function getstockrange(parm1 As range, _ parm2 As range, _ parm3 As range, _ parm4 As range, _ parm5 As range) As Range Set c1 = parm3.Find(parm2, LookIn:=xlValues) Set c2 = parm5.Find(parm4, LookIn:=xlValues) Set getstockrange = Range(parm1, _ Cells(c1.Row, c2.Column)) End Function "ctallen23 via OfficeKB.com" wrote: Hi. I have another question. I am trying to post this: OFFSET($A$4,MATCH (C21,$A$5:$A$17,0),MATCH(D21,$B$4:$M$4,0)) into a vba program but can't get it to work. I understand that the $$ are not recognized in vba and also, how would I go about putting this equation into a sub procedure? I tried calling it price = offset(....... Also, this is a set range that will not move. How can the program be structured to where $a$4 will always be the range or array's starting point? I have stock symbols in a row with dates down the left column. Stock prices fill the range. thansk. chris -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200707/1 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Joel wrote:
I haven't tested this code, but it should work. Because you hard coded location with $ they will never change. So you can put these locations directly into the function. =getstockrange(c21,D21) Function getstockrange(findparm1 As range, _ findparm2 As range) As Range Set c1 = Range("A5:A17"). _ Find(findparm1, LookIn:=xlValues) Set c2 = Range("B4:M4"). _ Find(findparm2, LookIn:=xlValues) Set getstockrange = Range(Range("A4"), _ Cells(c1.Row, c2.Column)) End Function ---------------------------------------------------------------------------- another way is the following =getstockrange($A$4,c21,$A$5:$A$17,D21,$B$4:$M$ 4) Function getstockrange(parm1 As range, _ parm2 As range, _ parm3 As range, _ parm4 As range, _ parm5 As range) As Range Set c1 = parm3.Find(parm2, LookIn:=xlValues) Set c2 = parm5.Find(parm4, LookIn:=xlValues) Set getstockrange = Range(parm1, _ Cells(c1.Row, c2.Column)) End Function Hi. I have another question. I am trying to post this: OFFSET($A$4,MATCH (C21,$A$5:$A$17,0),MATCH(D21,$B$4:$M$4,0)) into a vba program but can't get [quoted text clipped - 8 lines] chris I never knew about the hard coding aspect of VBA. Just barely scratching the surface with this. I will try this shortly to see what I get. Thank you. chris -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200707/1 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is there a way of making this a Sub procedure to where who ever is using it
can simply click the macro and have two questions asked: 1) date, 2) stock symbol and then the procedure will output via Msgbox the price? thanks again. chris -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...mming/200707/1 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Is there a way to unload the loaded XLL file in Excel? Hi all, I amdebugging XLL link library using Visual C++. Everytime I rebuild the XLL, Ihave to close the whole Excel program and relaunch the Excel program again,and then load in the newly gene | Excel Discussion (Misc queries) | |||
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul | Excel Worksheet Functions | |||
Find, Copy offset to offset on other sheet, Run-time 1004. | Excel Programming | |||
Problem with Range.Cells.Offset and Range.Cells( row + offset, column) | Excel Programming | |||
merging excel program with tdc finance program | Excel Programming |