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

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default vba offset program


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default vba offset program

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default vba offset program

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default vba offset program

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
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
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 LunaMoon Excel Discussion (Misc queries) 0 July 28th 08 11:03 PM
Compare Cell Values, Offset(-1,0), Offset(-1,-1), and xlFillDefaul RyGuy Excel Worksheet Functions 2 September 28th 07 10:54 PM
Find, Copy offset to offset on other sheet, Run-time 1004. Finny[_3_] Excel Programming 10 December 7th 06 11:46 PM
Problem with Range.Cells.Offset and Range.Cells( row + offset, column) [email protected] Excel Programming 2 August 22nd 05 05:25 AM
merging excel program with tdc finance program judy Excel Programming 0 November 5th 03 08:01 PM


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