View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Offsetting a Range

It depends on what you I value is. If I - 1 is negative you will fail
because you rows start at 1. Offsetting Row 1 by -1 will get Row 0 which
will create an error.

"awright" wrote:


Here's what I have so far:

Lvalue = Sheets("Historical Load").Range("A2").Value
Set IRange = Sheets("Historical Load").Range("C1:BA1").Offset(i - 1,
0)
Set Vrange = Sheets("Historical Load").Range("C8:BA8")
Set MyCell = Sheets("Nomination").Range("H1")
MyCell.Offset(i - 1, 0).Value = Application.WorksheetFunction.index _
(IRange, 1, Application.WorksheetFunction.Match(Lvalue, Vrange,
False))

This is part of a For - Next loop, where i is an integer.

In that second row, I want to Offset that entire range ("C1:BA1") by the
amount i - 1.

I think it's not working because Offset is usually for a single cell. Does
anyone have any suggestions for getting this to work?

Thanks!

Alex