Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default relative position in macro

I have a macro that opens a file (rider.xls) and looks up some values i
another file (master.xls) and dumps the result in the first fil
(rider.xls)

seems that lookup is using my current active cell position (from th
rider.xls file) to offset itself in the master file.

I want to reference the cell in master directly, regardless of th
position in the rider.xls file.

here is one of the formulas.

ActiveCell.FormulaR1C1 = _
"=INDEX([Master.xls]defenition!R6C1:R80C5,
MATCH([Master.xls]Master1!*R[-8]* C[" & 26 + counter & "],
[Master.xls]defenition!R6C1:R130C1,)
MATCH(R15C5,[Master.xls]defenition!R6C1:R6C5,))"


My problem comes from the R[-8]. it's negative 8 because in th
rider file my cell was at A16 and in the master I actually want AE
for example. so it goes back 8 rows

can't I simply reference to the cell in master.xls directly, no
relative to my other file??

I don't understand why that reference is relative and the other one
aren't (i.e. R6C1) in the same formula

P.S. the value of -8 actualy is calculated form a formula. I put -8 i
the example so that you see what the first one would look like.
The first time it;s -8 but it then it cahnges depending on the lookup


thanks

Pab

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default relative position in macro

Make
R[-8] as R8 and it will be absolute. You should probably remove the [
and ] from C[" & 26 + counter & "],


--
Regards,
Tom Ogilvy

pabs wrote in message
...
I have a macro that opens a file (rider.xls) and looks up some values in
another file (master.xls) and dumps the result in the first file
(rider.xls)

seems that lookup is using my current active cell position (from the
rider.xls file) to offset itself in the master file.

I want to reference the cell in master directly, regardless of the
position in the rider.xls file.

here is one of the formulas.

ActiveCell.FormulaR1C1 = _
"=INDEX([Master.xls]defenition!R6C1:R80C5,
MATCH([Master.xls]Master1!*R[-8]* C[" & 26 + counter & "],
[Master.xls]defenition!R6C1:R130C1,),
MATCH(R15C5,[Master.xls]defenition!R6C1:R6C5,))"


My problem comes from the R[-8]. it's negative 8 because in the
rider file my cell was at A16 and in the master I actually want AE8
for example. so it goes back 8 rows

can't I simply reference to the cell in master.xls directly, not
relative to my other file??

I don't understand why that reference is relative and the other ones
aren't (i.e. R6C1) in the same formula

P.S. the value of -8 actualy is calculated form a formula. I put -8 in
the example so that you see what the first one would look like.
The first time it;s -8 but it then it cahnges depending on the lookup


thanks

Pabs


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default relative position in macro

I can't do that since I actually pass a formula.. I simply put -8 to
show the value it was returning

R["&someFormula &"] and teh Result of someFormula has to be -8 in order
for it to work.. because it's relative to my Rider.xls" file.

I just want to be able to reference it directly to teh MAster.xls file
so that my formula would simply return the exact row location in the
MAster file ..


Pabs


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default relative position in macro

You seem to be missing the point.

R" & someformula & "

rather than with the brackets if you want the reference to be absolute. If
someformula returns a value between 1 and 65536 inclusive, then it is a
valid expression.

--
Regards,
Tom Ogilvy

pabs wrote in message
...
I can't do that since I actually pass a formula.. I simply put -8 to
show the value it was returning

R["&someFormula &"] and teh Result of someFormula has to be -8 in order
for it to work.. because it's relative to my Rider.xls" file.

I just want to be able to reference it directly to teh MAster.xls file
so that my formula would simply return the exact row location in the
MAster file ..


Pabs


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default relative position in macro

hehe... stupid mistake on my part..I tried what you had said the firs
time and I was getting errors...I thought the syntax was off

turns out my formula was still passing a negative number..that's why i
didn't work..

works fine now :)

thanks TO

--
Message posted from http://www.ExcelForum.com

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
How to macro to relative position jk9533 Excel Discussion (Misc queries) 6 October 15th 07 08:11 PM
Array to find relative position - is there a better way? John Michl Excel Worksheet Functions 3 October 8th 07 04:47 PM
Relative position of Employees Bob Davison Excel Worksheet Functions 9 May 8th 07 07:23 PM
Visual Basic Macros, relative position [email protected] Charts and Charting in Excel 3 November 14th 06 11:33 PM
Relative Cell position NOT working with or without macro Scratching my Head Excel Discussion (Misc queries) 6 May 30th 05 06:12 PM


All times are GMT +1. The time now is 07:28 AM.

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

About Us

"It's about Microsoft Excel"