Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get row number to change for a formula array? 1

Status
Not open for further replies.

makeitwork09

Technical User
Joined
Sep 28, 2009
Messages
170
Location
US
The following is a snippet of VBA code using Excel 2007

Code:
.Range(.Cells(2, FNRemCol + 1), .Cells(FNRemRow, FNRemCol +
1)).FormulaArray = "=IF(ISNA(INDEX(" & FNCCurtAdr & ",MATCH(" & FNRInvLnNo & "2&" & FNRPrinBal & "2," & FNCLoanNumAdr & "&" & FNCPrinBalAdr & ",0)," & FNCurtCol + 1 & ")),0,INDEX(" & FNCCurtAdr & ",MATCH(" & FNRInvLnNo & "2&" & FNRPrinBal & "2," & FNCLoanNumAdr & "&" & FNCPrinBalAdr & ",0)," & FNCurtCol + 1 & "))"

I was expecting that following pulled from above would change for each row like it does when using the formula property, but for the formula array it stays as F2 & N2 (relative references) for each row in the range. Is that because I should be using the R1C1 reference style instead? If not, how can change this so that
the row number for the portion below will change on each row?

Code:
FNRInvLnNo & "2&" & FNRPrinBal & "2

Note that the variables are anyone of the following A1 reference style cell letters, ranges, or column numbers.

Thanks
 
An example of range code that I am currently using with the xlA1 style

Code:
FNCLoanNumCol = Application.Match("InvLnNum", .Range("1:1"), 0)
FNCLoanNumLet = Replace(Cells(1, FNCLoanNumCol).Address(0, 0, xlA1, False), 1, "")
Set FNCLoanNumRng = .Range(FNCLoanNumLet & "2:" & FNCLoanNumLet & FNCurtRow)
FNCLoanNumAdr = "'" & FNCLoanNumRng.Parent.Name & "'!" & FNCLoanNumRng.Address(external:=False)
 


hi,

Either COPY the first occurrence and PASTE into the range in that column OR change each ROW reference in the loop. The former is quicker.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks Skip, that's what I was considering, but wasn't sure that was the right direction.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top