ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help using indirect to reference a defined range in another spread (https://www.excelbanter.com/excel-programming/409055-help-using-indirect-reference-defined-range-another-spread.html)

Quietman

Help using indirect to reference a defined range in another spread
 
The indirect is pointing to the cell that has the name of the defined range
that is referenced to another file.

Thanks

Sub Add_Data_Pull_Formulas_New()
Application.ScreenUpdating = False
Application.Calculation = xlManual
Current_Sheet = ActiveSheet.Name

Set RangeToCheck = ActiveCell.CurrentRegion
Set NewRange = Range(RangeToCheck.Cells(8, 2),
RangeToCheck.Cells(RangeToCheck.Rows.Count, RangeToCheck.Columns.Count))
ActiveWorkbook.Names.Add Name:=Current_Sheet, RefersToR1C1:=NewRange

With Range(Current_Sheet)
.FormulaR1C1 =
"=SUMIF(NDIRECT(R5C),RC1,OFFSET(NDIRECT(R5C),0,R1C ,ROWS(NDIRECT(R5C)),1))"
.Value = .Value
End With
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub


--
Helping Is always a good thing


All times are GMT +1. The time now is 12:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com