# index Reference letter change when i insert a column in refrence sheet

#### AbdulkareemAlhassni

##### New Member
hi guys,

i have an issue where the following index letter \$E7\$:\$E\$100000 changes whenever i enter a call to refrence sheet "Raw Data for PR Dist"

Code:
``=IF(INDEX('Raw Data for PR Dist'!\$E\$7:\$E\$100000,MATCH(1,(A3='Raw Data for PR Dist'!\$A\$7:\$A\$100000)*(B3='Raw Data for PR Dist'!\$B\$7:\$B\$100000),0))="","",INDEX('Raw Data for PR Dist'!\$E\$7:\$E\$100000,MATCH(1,(A3='Raw Data for PR Dist'!\$A\$7:\$A\$100000)*(B3='Raw Data for PR Dist'!\$B\$7:\$B\$100000),0)))``

such as when i run the vba the first time it will insert a column in the refrence sheet.

every time i run the Macro the same thing happen, thus \$E7\$:\$E\$100000 becomes \$F7\$:\$F\$100000 then \$G7\$:\$G\$100000...etc

how can i lock \$E7\$:\$E\$100000 to NOT change whenever i run the Macro ?

i saw something about indirect but am not sure if it will work or if there is a better solution.

THank you

### Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

#### Gerald Higgins

##### Well-known Member
Are you inserting a column to the left of column E ?
If yes, then I'm not sure how to get round that.
One way, perhaps, would be to add some code to your existing macro so that it re-writes this formula correctly each time the code runs.

#### AbdulkareemAlhassni

##### New Member
Are you inserting a column to the left of column E ?
If yes, then I'm not sure how to get round that.
One way, perhaps, would be to add some code to your existing macro so that it re-writes this formula correctly each time the code runs.
i tried to re-write it but am getting error for Array

Code:
``````[COLOR=#0000BB][FONT=monospace]Range[/FONT][/COLOR][COLOR=#007700][FONT=monospace]([/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]"D3"[/FONT][/COLOR][COLOR=#007700][FONT=monospace]).[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]Select    Selection[/FONT][/COLOR][COLOR=#007700][FONT=monospace].[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]FormulaArray [/FONT][/COLOR][COLOR=#007700][FONT=monospace]= [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]_
[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]  Range[/FONT][/COLOR][COLOR=#007700][FONT=monospace]([/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]"D3"[/FONT][/COLOR][COLOR=#007700][FONT=monospace]).[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]Select    Selection[/FONT][/COLOR][COLOR=#007700][FONT=monospace].[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]FormulaArray [/FONT][/COLOR][COLOR=#007700][FONT=monospace]= [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]_
[/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]"=IF(INDEX('Raw Data for PR Dist'!R7C5:R100000C5,MATCH(1,('PR Dist SSD Report'!RC[-3]='Raw Data for PR Dist'!R7C1:R100000C1)*('PR Dist SSD Report'!RC[-2]='Raw Data for PR Dist'!R7C2:R100000C2),0))="""","""",INDEX('Raw Data for PR Dist'!R7C5:R100000C5,MATCH(1,('PR Dist SSD Report'!RC[-3]='Raw Data for PR Dist'!R7C1:R100000C1)*('PR Dist SSD Report'!RC[-2]='Raw Data for" [/FONT][/COLOR][COLOR=#007700][FONT=monospace]& [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]_       [/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]" PR Dist'!R7C2:R100000C2),0)))" [/FONT][/COLOR][COLOR=#007700][FONT=monospace]& [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]_        [/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]""            [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]Range[/FONT][/COLOR][COLOR=#007700][FONT=monospace]([/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]"E3"[/FONT][/COLOR][COLOR=#007700][FONT=monospace]).[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]Select    Selection[/FONT][/COLOR][COLOR=#007700][FONT=monospace].[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]FormulaArray [/FONT][/COLOR][COLOR=#007700][FONT=monospace]= [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]_        [/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]"=IF(INDEX('Raw Data for PR Dist'!R7C3:R100000C3,MATCH(1,('PR Dist SSD Report'!RC[-4]='Raw Data for PR Dist'!R7C1:R100000C1)*('PR Dist SSD Report'!RC[-3]='Raw Data for PR Dist'!R7C2:R100000C2),0))="""","""",INDEX('Raw Data for PR Dist'!R7C3:R100000C3,MATCH(1,('PR Dist SSD Report'!RC[-4]='Raw Data for PR Dist'!R7C1:R100000C1)*('PR Dist SSD Report'!RC[-3]='Raw Data for" [/FONT][/COLOR][COLOR=#007700][FONT=monospace]& [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]_        [/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]" PR Dist'!R7C2:R100000C2),0)))" [/FONT][/COLOR][COLOR=#007700][FONT=monospace]& [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]_        [/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]""            [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]Range[/FONT][/COLOR][COLOR=#007700][FONT=monospace]([/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]"F3"[/FONT][/COLOR][COLOR=#007700][FONT=monospace]).[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]Select    Selection[/FONT][/COLOR][COLOR=#007700][FONT=monospace].[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]FormulaArray [/FONT][/COLOR][COLOR=#007700][FONT=monospace]= [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]_        [/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]"=IF(INDEX('Raw Data for PR Dist'!R7C4:R100000C4,MATCH(1,('PR Dist SSD Report'!RC[-5]='Raw Data for PR Dist'!R7C1:R100000C1)*('PR Dist SSD Report'!RC[-4]='Raw Data for PR Dist'!R7C2:R100000C2),0))="""","""",INDEX('Raw Data for PR Dist'!R7C4:R100000C4,MATCH(1,('PR Dist SSD Report'!RC[-5]='Raw Data for PR Dist'!R7C1:R100000C1)*('PR Dist SSD Report'!RC[-4]='Raw Data for" [/FONT][/COLOR][COLOR=#007700][FONT=monospace]& [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]_        [/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]" PR Dist'!R7C2:R100000C2),0)))" [/FONT][/COLOR][COLOR=#007700][FONT=monospace]& [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]_        [/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]""            [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]Range[/FONT][/COLOR][COLOR=#007700][FONT=monospace]([/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]"J3"[/FONT][/COLOR][COLOR=#007700][FONT=monospace]).[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]Select    Selection[/FONT][/COLOR][COLOR=#007700][FONT=monospace].[/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]FormulaArray [/FONT][/COLOR][COLOR=#007700][FONT=monospace]= [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]_        [/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]"=IF(INDEX('Raw Data for PR Dist'!R7C35:R100000C35,MATCH(1,('PR Dist SSD Report'!RC[-9]='Raw Data for PR Dist'!R7C1:R100000C1)*('PR Dist SSD Report'!RC[-8]='Raw Data for PR Dist'!R7C2:R100000C2),0))="""","""",INDEX('Raw Data for PR Dist'!R7C35:R100000C35,MATCH(1,('PR Dist SSD Report'!RC[-9]='Raw Data for PR Dist'!R7C1:R100000C1)*('PR Dist SSD Report'!RC[-8]='Raw Data" [/FONT][/COLOR][COLOR=#007700][FONT=monospace]& [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]_        [/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]" for PR Dist'!R7C2:R100000C2),0)))" [/FONT][/COLOR][COLOR=#007700][FONT=monospace]& [/FONT][/COLOR][COLOR=#0000BB][FONT=monospace]_        [/FONT][/COLOR][COLOR=#DD0000][FONT=monospace]""[/FONT][/COLOR]``````

Error ( 1004 VBA unable to set the formulaarray probery of the range class)

How can i fix it ?

i recorded the ( Writing the code then pasting it ) cuz i want it to automatically do it.

and also

would INDIRECT() work ?

Last edited:

#### Gerald Higgins

##### Well-known Member
Do you want this to be an array formula ?
I can't even get this to be an array formula - pressing F2, then Control, Shift, Enter (which is the way I normally turn a formula into an array formula) doesn't seem to take any effect.
I'm not an expert on array formulas - could it be something to do with the formula referring to another worksheet ?
When I try this without the reference to another worksheet - in other words making the formula refer to the same worksheet that the formula sits on - it all seems to work OK.

#### AbdulkareemAlhassni

##### New Member
Do you want this to be an array formula ?
I can't even get this to be an array formula - pressing F2, then Control, Shift, Enter (which is the way I normally turn a formula into an array formula) doesn't seem to take any effect.
I'm not an expert on array formulas - could it be something to do with the formula referring to another worksheet ?
When I try this without the reference to another worksheet - in other words making the formula refer to the same worksheet that the formula sits on - it all seems to work OK.
because it is referring to another sheet

and this other sheet adds multiple columns when it runs everytime in the refrence sheet

the formula cell refrencing the other sheet gets updated

1,102,842
Messages
5,489,204
Members
407,678
Latest member
Matt1989

### This Week's Hot Topics

• Timer in VBA - Stop, Start, Pause and Reset
[CODE=vba][/CODE] Option Explicit Dim CmdStop As Boolean Dim Paused As Boolean Dim Start Dim TimerValue As Date Dim pausedTime As Date Sub...
• how to updates multiple rows in muliselect listbox
Hello everyone. I need help with below code. code is only chaning 1st row in mulitiselect list box. i know issue with code...
• Delete Row from Table
I am trying to delete a row from a table using VBA using a named range to find what I need to delete. My Range is finding the right cell. In the...
• Assigning to a variable
I have a for each block where I want to assign the value in column 5 of the found row to the variable Serv. [CODE=vba] For Each ws In...
• Way to verify information
Hi All, I don't know what to call this formula, and therefore can't search. I have a spreadsheet with information I want to reference...
• Active Cell Address – Inactive Sheet
How to use VBA to get the cell address of the active cell in an inactive worksheet and then place that cell address in a location on the current...