How to update formulas in a number of cells based on number reference from adjacent cells












0















I have a file displaying sale locations on a physical floor. These cells are formulated to display various indexes by returning values from another sheet ; adjacent to these locations is a position number ranging from 1 to 250 that can be to the left, above, to the right or below the location. I am looking for the most optimized way to update the formulas in the locations cells based on the position number filled into the adjacent cell so for example if position changes from 2 to 3 when running a macro the location formula should change from =TOTALS!$V$11 to =TOTALS!$V$12 where $V$12 comes from position 3+9 rows..



I can provide sample file



Tried Interior.ColorIndex, R1C1 formulas etc.



Started with identifying the colors did not get to the formula part.



Sub Test1()

'white is -4142
'pink color index 38
'green color index 10
'red color index 3
'turcoise color index 8
'yellow color index 6
'blue color index 5
'purple color index 13

Selection.Offset(0, -1).Select

Range(Left(Selection.Address, InStr(Selection.Address, ":") - 1)).Interior.ColorIndex


For Each possValue In Selection

If Selection.Interior.ColorIndex = 5 Or Selection.Interior.ColorIndex = 38 Then
If Left(Selection.Offset(0, -1).Address, InStr(Selection.Offset(0, -1).Address, ":") - 1).Interior.ColorIndex = -4142 And Left(Selection.Offset(0, -1).Address, InStr(Selection.Offset(0, -1).Address, ":") - 1).HasFormula = False Then

MsgBox Left(Selection.Offset(0, -1).Address, InStr(Selection.Offset(0, -1).Address, ":") - 1).Value

End If

End If

Next possValue

End Sub


I have a file displaying sale locations on a physical floor. These cells are formulated to display various indexes by returning values from another sheet ; adjacent to these locations is a position number ranging from 1 to 250 that can be to the left, above, to the right or below the location. I am looking for the most optimized way to update the formulas in the locations cells based on the position number filled into the adjacent cell so for example if position changes from 2 to 3 when running a macro the location formula should change from =TOTALS!$V$11 to =TOTALS!$V$12 where $V$12 comes from position 3+9 rows..



enter image description here










share|improve this question

























  • Asking for the most optimized way would make this question Too Broad, leading to closure, though may be more appropriate for another site like Code Review (they help optimize code which does run). Can you update your question to relate to the code you've provided, as there should be many ways to get to what you're asking (though I'm honestly a bit confused in your explanation of the data for what it looks like you're asking)?

    – Cyril
    Jan 2 at 19:55













  • How can I update question?

    – Raul
    Jan 2 at 20:09











  • On the bottom of your post there are buttons for "share", "edit", and "flag"... click edit. you should be able to search for the word "edit" using ctrl+f if need be.

    – Cyril
    Jan 2 at 20:26
















0















I have a file displaying sale locations on a physical floor. These cells are formulated to display various indexes by returning values from another sheet ; adjacent to these locations is a position number ranging from 1 to 250 that can be to the left, above, to the right or below the location. I am looking for the most optimized way to update the formulas in the locations cells based on the position number filled into the adjacent cell so for example if position changes from 2 to 3 when running a macro the location formula should change from =TOTALS!$V$11 to =TOTALS!$V$12 where $V$12 comes from position 3+9 rows..



I can provide sample file



Tried Interior.ColorIndex, R1C1 formulas etc.



Started with identifying the colors did not get to the formula part.



Sub Test1()

'white is -4142
'pink color index 38
'green color index 10
'red color index 3
'turcoise color index 8
'yellow color index 6
'blue color index 5
'purple color index 13

Selection.Offset(0, -1).Select

Range(Left(Selection.Address, InStr(Selection.Address, ":") - 1)).Interior.ColorIndex


For Each possValue In Selection

If Selection.Interior.ColorIndex = 5 Or Selection.Interior.ColorIndex = 38 Then
If Left(Selection.Offset(0, -1).Address, InStr(Selection.Offset(0, -1).Address, ":") - 1).Interior.ColorIndex = -4142 And Left(Selection.Offset(0, -1).Address, InStr(Selection.Offset(0, -1).Address, ":") - 1).HasFormula = False Then

MsgBox Left(Selection.Offset(0, -1).Address, InStr(Selection.Offset(0, -1).Address, ":") - 1).Value

End If

End If

Next possValue

End Sub


I have a file displaying sale locations on a physical floor. These cells are formulated to display various indexes by returning values from another sheet ; adjacent to these locations is a position number ranging from 1 to 250 that can be to the left, above, to the right or below the location. I am looking for the most optimized way to update the formulas in the locations cells based on the position number filled into the adjacent cell so for example if position changes from 2 to 3 when running a macro the location formula should change from =TOTALS!$V$11 to =TOTALS!$V$12 where $V$12 comes from position 3+9 rows..



enter image description here










share|improve this question

























  • Asking for the most optimized way would make this question Too Broad, leading to closure, though may be more appropriate for another site like Code Review (they help optimize code which does run). Can you update your question to relate to the code you've provided, as there should be many ways to get to what you're asking (though I'm honestly a bit confused in your explanation of the data for what it looks like you're asking)?

    – Cyril
    Jan 2 at 19:55













  • How can I update question?

    – Raul
    Jan 2 at 20:09











  • On the bottom of your post there are buttons for "share", "edit", and "flag"... click edit. you should be able to search for the word "edit" using ctrl+f if need be.

    – Cyril
    Jan 2 at 20:26














0












0








0








I have a file displaying sale locations on a physical floor. These cells are formulated to display various indexes by returning values from another sheet ; adjacent to these locations is a position number ranging from 1 to 250 that can be to the left, above, to the right or below the location. I am looking for the most optimized way to update the formulas in the locations cells based on the position number filled into the adjacent cell so for example if position changes from 2 to 3 when running a macro the location formula should change from =TOTALS!$V$11 to =TOTALS!$V$12 where $V$12 comes from position 3+9 rows..



I can provide sample file



Tried Interior.ColorIndex, R1C1 formulas etc.



Started with identifying the colors did not get to the formula part.



Sub Test1()

'white is -4142
'pink color index 38
'green color index 10
'red color index 3
'turcoise color index 8
'yellow color index 6
'blue color index 5
'purple color index 13

Selection.Offset(0, -1).Select

Range(Left(Selection.Address, InStr(Selection.Address, ":") - 1)).Interior.ColorIndex


For Each possValue In Selection

If Selection.Interior.ColorIndex = 5 Or Selection.Interior.ColorIndex = 38 Then
If Left(Selection.Offset(0, -1).Address, InStr(Selection.Offset(0, -1).Address, ":") - 1).Interior.ColorIndex = -4142 And Left(Selection.Offset(0, -1).Address, InStr(Selection.Offset(0, -1).Address, ":") - 1).HasFormula = False Then

MsgBox Left(Selection.Offset(0, -1).Address, InStr(Selection.Offset(0, -1).Address, ":") - 1).Value

End If

End If

Next possValue

End Sub


I have a file displaying sale locations on a physical floor. These cells are formulated to display various indexes by returning values from another sheet ; adjacent to these locations is a position number ranging from 1 to 250 that can be to the left, above, to the right or below the location. I am looking for the most optimized way to update the formulas in the locations cells based on the position number filled into the adjacent cell so for example if position changes from 2 to 3 when running a macro the location formula should change from =TOTALS!$V$11 to =TOTALS!$V$12 where $V$12 comes from position 3+9 rows..



enter image description here










share|improve this question
















I have a file displaying sale locations on a physical floor. These cells are formulated to display various indexes by returning values from another sheet ; adjacent to these locations is a position number ranging from 1 to 250 that can be to the left, above, to the right or below the location. I am looking for the most optimized way to update the formulas in the locations cells based on the position number filled into the adjacent cell so for example if position changes from 2 to 3 when running a macro the location formula should change from =TOTALS!$V$11 to =TOTALS!$V$12 where $V$12 comes from position 3+9 rows..



I can provide sample file



Tried Interior.ColorIndex, R1C1 formulas etc.



Started with identifying the colors did not get to the formula part.



Sub Test1()

'white is -4142
'pink color index 38
'green color index 10
'red color index 3
'turcoise color index 8
'yellow color index 6
'blue color index 5
'purple color index 13

Selection.Offset(0, -1).Select

Range(Left(Selection.Address, InStr(Selection.Address, ":") - 1)).Interior.ColorIndex


For Each possValue In Selection

If Selection.Interior.ColorIndex = 5 Or Selection.Interior.ColorIndex = 38 Then
If Left(Selection.Offset(0, -1).Address, InStr(Selection.Offset(0, -1).Address, ":") - 1).Interior.ColorIndex = -4142 And Left(Selection.Offset(0, -1).Address, InStr(Selection.Offset(0, -1).Address, ":") - 1).HasFormula = False Then

MsgBox Left(Selection.Offset(0, -1).Address, InStr(Selection.Offset(0, -1).Address, ":") - 1).Value

End If

End If

Next possValue

End Sub


I have a file displaying sale locations on a physical floor. These cells are formulated to display various indexes by returning values from another sheet ; adjacent to these locations is a position number ranging from 1 to 250 that can be to the left, above, to the right or below the location. I am looking for the most optimized way to update the formulas in the locations cells based on the position number filled into the adjacent cell so for example if position changes from 2 to 3 when running a macro the location formula should change from =TOTALS!$V$11 to =TOTALS!$V$12 where $V$12 comes from position 3+9 rows..



enter image description here







excel vba excel-vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 7 at 8:47









Pᴇʜ

24.9k63052




24.9k63052










asked Jan 2 at 19:27









RaulRaul

1




1













  • Asking for the most optimized way would make this question Too Broad, leading to closure, though may be more appropriate for another site like Code Review (they help optimize code which does run). Can you update your question to relate to the code you've provided, as there should be many ways to get to what you're asking (though I'm honestly a bit confused in your explanation of the data for what it looks like you're asking)?

    – Cyril
    Jan 2 at 19:55













  • How can I update question?

    – Raul
    Jan 2 at 20:09











  • On the bottom of your post there are buttons for "share", "edit", and "flag"... click edit. you should be able to search for the word "edit" using ctrl+f if need be.

    – Cyril
    Jan 2 at 20:26



















  • Asking for the most optimized way would make this question Too Broad, leading to closure, though may be more appropriate for another site like Code Review (they help optimize code which does run). Can you update your question to relate to the code you've provided, as there should be many ways to get to what you're asking (though I'm honestly a bit confused in your explanation of the data for what it looks like you're asking)?

    – Cyril
    Jan 2 at 19:55













  • How can I update question?

    – Raul
    Jan 2 at 20:09











  • On the bottom of your post there are buttons for "share", "edit", and "flag"... click edit. you should be able to search for the word "edit" using ctrl+f if need be.

    – Cyril
    Jan 2 at 20:26

















Asking for the most optimized way would make this question Too Broad, leading to closure, though may be more appropriate for another site like Code Review (they help optimize code which does run). Can you update your question to relate to the code you've provided, as there should be many ways to get to what you're asking (though I'm honestly a bit confused in your explanation of the data for what it looks like you're asking)?

– Cyril
Jan 2 at 19:55







Asking for the most optimized way would make this question Too Broad, leading to closure, though may be more appropriate for another site like Code Review (they help optimize code which does run). Can you update your question to relate to the code you've provided, as there should be many ways to get to what you're asking (though I'm honestly a bit confused in your explanation of the data for what it looks like you're asking)?

– Cyril
Jan 2 at 19:55















How can I update question?

– Raul
Jan 2 at 20:09





How can I update question?

– Raul
Jan 2 at 20:09













On the bottom of your post there are buttons for "share", "edit", and "flag"... click edit. you should be able to search for the word "edit" using ctrl+f if need be.

– Cyril
Jan 2 at 20:26





On the bottom of your post there are buttons for "share", "edit", and "flag"... click edit. you should be able to search for the word "edit" using ctrl+f if need be.

– Cyril
Jan 2 at 20:26












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54012090%2fhow-to-update-formulas-in-a-number-of-cells-based-on-number-reference-from-adjac%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54012090%2fhow-to-update-formulas-in-a-number-of-cells-based-on-number-reference-from-adjac%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

A Topological Invariant for $pi_3(U(n))$