Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default R1C1 format and variable ranges

i'm using UsedRange.Columns.Count on a download file to determine number of
columns (which will increase over time) and am using a lookup formula to pull
data out of that file and into a model.

i am copying that formula over the same number of columns in the model.
problem is, the recorded macro has fixed values which won't handle an
increase. what kind of code will allow my formula to be copied over a
changing number of columns? if this has been discussed previously please
reference those posts, thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default R1C1 format and variable ranges

It would be easier to answer if you showed your code for the lookup.

"mwam423" wrote:

i'm using UsedRange.Columns.Count on a download file to determine number of
columns (which will increase over time) and am using a lookup formula to pull
data out of that file and into a model.

i am copying that formula over the same number of columns in the model.
problem is, the recorded macro has fixed values which won't handle an
increase. what kind of code will allow my formula to be copied over a
changing number of columns? if this has been discussed previously please
reference those posts, thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default R1C1 format and variable ranges

hi barb, thanks for response, here's the formula. note, dropper is variable
which is determined by date. just realized, could i replace the 6 in
ActiveCell.Offset with a variable based on RangeUsed.Columns.Count?

ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[" & -(dropper - 1) & "]C,MW118487750.xls!C2:C9,8,FALSE)"
ActiveCell.Copy
Range(Selection, ActiveCell.Offset(, 6)).Select




"Barb Reinhardt" wrote:

It would be easier to answer if you showed your code for the lookup.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default R1C1 format and variable ranges

In order to ensure that the data is being extracted from the right column,
you need to change this:

"=VLOOKUP(R[" & -(dropper - 1) & "]C
to something like this
"=VLOOKUP(R[" & -(dropper - 1) & "]C1

Make sense?

HTH,
Barb Reinhardt
"mwam423" wrote:

hi barb, thanks for response, here's the formula. note, dropper is variable
which is determined by date. just realized, could i replace the 6 in
ActiveCell.Offset with a variable based on RangeUsed.Columns.Count?

ActiveCell.FormulaR1C1 = _
"=VLOOKUP(R[" & -(dropper - 1) & "]C,MW118487750.xls!C2:C9,8,FALSE)"
ActiveCell.Copy
Range(Selection, ActiveCell.Offset(, 6)).Select




"Barb Reinhardt" wrote:

It would be easier to answer if you showed your code for the lookup.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default R1C1 format and variable ranges

not sure why C isn't referenced with a number, obtain good results across
columns, but will add the column number. any ideas bout how to copy to a
variable amount of columns


"Barb Reinhardt" wrote:

In order to ensure that the data is being extracted from the right column,
you need to change this:

"=VLOOKUP(R[" & -(dropper - 1) & "]C
to something like this
"=VLOOKUP(R[" & -(dropper - 1) & "]C1

Make sense?




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default R1C1 format and variable ranges

shouldn't C be zero? that value is relative to cell where formula is, and
it's picking up info from the top row of the same column . .

"Barb Reinhardt" wrote:

In order to ensure that the data is being extracted from the right column,
you need to change this:

"=VLOOKUP(R[" & -(dropper - 1) & "]C
to something like this
"=VLOOKUP(R[" & -(dropper - 1) & "]C1

Make sense?


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default R1C1 format and variable ranges

It's difficult to guess what you want.

We don't know what dropper is equal to. We don't know the location of the
activecell. And we don't know what that formula is really trying to do.

You may need to give more description to get more help.

mwam423 wrote:

shouldn't C be zero? that value is relative to cell where formula is, and
it's picking up info from the top row of the same column . .

"Barb Reinhardt" wrote:

In order to ensure that the data is being extracted from the right column,
you need to change this:

"=VLOOKUP(R[" & -(dropper - 1) & "]C
to something like this
"=VLOOKUP(R[" & -(dropper - 1) & "]C1

Make sense?


--

Dave Peterson
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
Counting variable ranges and auto-summing variable ranges Father Guido[_5_] Excel Programming 2 March 29th 06 04:07 AM
R1C1 format using a variable? jim37055 Excel Discussion (Misc queries) 3 October 4th 05 05:47 PM
referencing ranges using R1C1 format pwermuth[_2_] Excel Programming 6 July 9th 05 02:19 AM
referencing ranges using R1C1 format pwermuth Excel Programming 2 July 6th 05 03:15 AM
Variable Reference in R1C1 format Ndel40[_2_] Excel Programming 1 February 20th 04 10:21 PM


All times are GMT +1. The time now is 09:32 AM.

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"