willwill88
New Member
- Joined
- Dec 8, 2011
- Messages
- 5
Hi,
I'm trying to make an array formula with vba where the logical test stops at the last row. I'm hoping this will speed up the macro instead of scanning a whole column C:C for example, which could have 2,000 - 600,000+ rows.
Sheet 1 has the data
Sheet 4 is where im putting the fomula
I was hoping this forumla would work but no dice. Any help would be appreciated.
Selection.FormulaArray = _
"=MAX(IF(C2=(Sheet1(C2:C & LastRow),(Sheet1.Range(U2:U & LastRow),""""))"
I'm trying to make an array formula with vba where the logical test stops at the last row. I'm hoping this will speed up the macro instead of scanning a whole column C:C for example, which could have 2,000 - 600,000+ rows.
Sheet 1 has the data
Sheet 4 is where im putting the fomula
I was hoping this forumla would work but no dice. Any help would be appreciated.
Selection.FormulaArray = _
"=MAX(IF(C2=(Sheet1(C2:C & LastRow),(Sheet1.Range(U2:U & LastRow),""""))"
Code:
Sheets(1).Activate
LastCol = Cells(2, Columns.Count).End(xlToLeft).Column
LastRow = Cells(Rows.Count, "B").End(xlUp).Row
Sheets(4).Activate
Range("AI2").Select
Code works but is slow
Selection.FormulaArray = _
"=MAX(IF(RC[-32]='Reservation Details By Date'!C[-32],'Reservation Details By Date'!C[-14],""""))"
'Error with this code
Selection.FormulaArray = _
"=MAX(IF(C2=(Sheet1(C2:C & LastRow),(Sheet1.Range(U2:U & LastRow),""""))"
'Error with this code
Selection.FormulaArray = _
"=MAX(IF(C[-32]=(Sheet1(C[-32] & LastRow),(Sheet1.Range(C[-14] & LastRow),""""))"