index Reference letter change when i insert a column in refrence sheet
Results 1 to 5 of 5

Thread: index Reference letter change when i insert a column in refrence sheet
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Nov 2018
    Posts
    41
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

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

    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

  2. #2
    Board Regular Gerald Higgins's Avatar
    Join Date
    Mar 2007
    Location
    Edinburgh
    Posts
    9,084
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Default Re: index Reference letter change when i insert a column in refrence sheet

    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.
    The following is my SIGNATURE. It's not part of any question or solution I'm posting. If it IS your solution, you've got a very weird problem !

    Sub Macro()
    ActiveCell = "IY" & Right(Application.Name, 5)
    With ActiveCell.Characters(Start:=2, Length:=1).Font
    .Name = "Webdings"
    .Color = 255
    End With
    End Sub

  3. #3
    New Member
    Join Date
    Nov 2018
    Posts
    41
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Default Re: index Reference letter change when i insert a column in refrence sheet

    Quote Originally Posted by Gerald Higgins View Post
    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:
    Range("D3").Select    Selection.FormulaArray = _   
            Range("D3").Select    Selection.FormulaArray = _   
         "=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" & _       " PR Dist'!R7C2:R100000C2),0)))" & _        ""            Range("E3").Select    Selection.FormulaArray = _        "=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" & _        " PR Dist'!R7C2:R100000C2),0)))" & _        ""            Range("F3").Select    Selection.FormulaArray = _        "=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" & _        " PR Dist'!R7C2:R100000C2),0)))" & _        ""            Range("J3").Select    Selection.FormulaArray = _        "=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" & _        " for PR Dist'!R7C2:R100000C2),0)))" & _        ""

    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 by AbdulkareemAlhassni; Aug 16th, 2019 at 11:49 AM.

  4. #4
    Board Regular Gerald Higgins's Avatar
    Join Date
    Mar 2007
    Location
    Edinburgh
    Posts
    9,084
    Post Thanks / Like
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Default Re: index Reference letter change when i insert a column in refrence sheet

    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.
    The following is my SIGNATURE. It's not part of any question or solution I'm posting. If it IS your solution, you've got a very weird problem !

    Sub Macro()
    ActiveCell = "IY" & Right(Application.Name, 5)
    With ActiveCell.Characters(Start:=2, Length:=1).Font
    .Name = "Webdings"
    .Color = 255
    End With
    End Sub

  5. #5
    New Member
    Join Date
    Nov 2018
    Posts
    41
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Default Re: index Reference letter change when i insert a column in refrence sheet

    Quote Originally Posted by Gerald Higgins View Post
    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

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •