Excel: can offset use a corresponding code as a value in another column?
First off, I've tried to do my research, but I'm so inexperienced I don't know what I don't know, and I don't know how to ask the right question. I'd imagine my whole issue is just not understanding the functionality of excel.
I'll start by explaining my story and goals - I'm open to trying a more efficient method!
TL;DR - I need to create some sort of column search function that offsets a value
My Story:
So, I am about to launch an online personal training business. One of my services is nutrition coaching, and I'll be creating weekly meal plans for clients. To create these meal plans I want to be able to create a 'preset meal' button that I can easily press to add a given preset to the meal plan. I've been operating inefficiently, where I manually enter the quantity of each ingredient each time. I have tables for the different food groups (meat, grains, dairy, fruit, veg, other), they will be set up like the following. In this example, one of the required ingredients is 2 slices of ham (see Column F);
This is the previously set up macro, it was selecting a given Cell, not finding the ingredient and inputing a value from an offset
Example of table now
Column A - Ingredient - e.g;
Meat Table;'pork_ham_slice'
Column B - Energy (kj) - e.g;
Meat Table;'460'
Column C:E - Carbs(g)|Protein(g)|Fat(g) - e.g;
Meat Table;'7'|'15'|'2.5'
Column F - Quantity - e.g; -
Meat Table;'2'
Column G - Energy (kj)x Column F - e.g;
Meat Table;'920'
Column H:J - [Carbs(g)|Protein(g)|Fat(g)]x Column F - e.g;
Meat Table;'14'|'30'|'5'
My Goal: I want to be able to create a button/macro that will search Column A for the given ingredient, before inputing a value into Column F. I had started creating a few buttons where they input values into a specific Cell in Column A, however, I will continually be adding more ingredients, and I want the Column A to be sorted alphabetically, which instantly throws off this set cell method as I add a new ingredient.
At the end of the day, I thought some combination of VLOOKUP and OFFSET could be used, but I just can't figure this one out - Youtube isn't enough, and here we are.
If any of this was unclear, I'm more than happy to provide further details!
Guy
excel vba excel-formula
add a comment |
First off, I've tried to do my research, but I'm so inexperienced I don't know what I don't know, and I don't know how to ask the right question. I'd imagine my whole issue is just not understanding the functionality of excel.
I'll start by explaining my story and goals - I'm open to trying a more efficient method!
TL;DR - I need to create some sort of column search function that offsets a value
My Story:
So, I am about to launch an online personal training business. One of my services is nutrition coaching, and I'll be creating weekly meal plans for clients. To create these meal plans I want to be able to create a 'preset meal' button that I can easily press to add a given preset to the meal plan. I've been operating inefficiently, where I manually enter the quantity of each ingredient each time. I have tables for the different food groups (meat, grains, dairy, fruit, veg, other), they will be set up like the following. In this example, one of the required ingredients is 2 slices of ham (see Column F);
This is the previously set up macro, it was selecting a given Cell, not finding the ingredient and inputing a value from an offset
Example of table now
Column A - Ingredient - e.g;
Meat Table;'pork_ham_slice'
Column B - Energy (kj) - e.g;
Meat Table;'460'
Column C:E - Carbs(g)|Protein(g)|Fat(g) - e.g;
Meat Table;'7'|'15'|'2.5'
Column F - Quantity - e.g; -
Meat Table;'2'
Column G - Energy (kj)x Column F - e.g;
Meat Table;'920'
Column H:J - [Carbs(g)|Protein(g)|Fat(g)]x Column F - e.g;
Meat Table;'14'|'30'|'5'
My Goal: I want to be able to create a button/macro that will search Column A for the given ingredient, before inputing a value into Column F. I had started creating a few buttons where they input values into a specific Cell in Column A, however, I will continually be adding more ingredients, and I want the Column A to be sorted alphabetically, which instantly throws off this set cell method as I add a new ingredient.
At the end of the day, I thought some combination of VLOOKUP and OFFSET could be used, but I just can't figure this one out - Youtube isn't enough, and here we are.
If any of this was unclear, I'm more than happy to provide further details!
Guy
excel vba excel-formula
Please show us your work sor far and your exact table structure - screenshots would be very helpful.
– Michal Rosa
Nov 20 '18 at 4:47
Please always include the code in your question and format it as code block. An image of your code is not helpful.
– Pᴇʜ
Nov 20 '18 at 7:27
1
You will find this very helpful in terms of speeding up your code by avoiding .Select.
– QHarr
Nov 20 '18 at 7:51
add a comment |
First off, I've tried to do my research, but I'm so inexperienced I don't know what I don't know, and I don't know how to ask the right question. I'd imagine my whole issue is just not understanding the functionality of excel.
I'll start by explaining my story and goals - I'm open to trying a more efficient method!
TL;DR - I need to create some sort of column search function that offsets a value
My Story:
So, I am about to launch an online personal training business. One of my services is nutrition coaching, and I'll be creating weekly meal plans for clients. To create these meal plans I want to be able to create a 'preset meal' button that I can easily press to add a given preset to the meal plan. I've been operating inefficiently, where I manually enter the quantity of each ingredient each time. I have tables for the different food groups (meat, grains, dairy, fruit, veg, other), they will be set up like the following. In this example, one of the required ingredients is 2 slices of ham (see Column F);
This is the previously set up macro, it was selecting a given Cell, not finding the ingredient and inputing a value from an offset
Example of table now
Column A - Ingredient - e.g;
Meat Table;'pork_ham_slice'
Column B - Energy (kj) - e.g;
Meat Table;'460'
Column C:E - Carbs(g)|Protein(g)|Fat(g) - e.g;
Meat Table;'7'|'15'|'2.5'
Column F - Quantity - e.g; -
Meat Table;'2'
Column G - Energy (kj)x Column F - e.g;
Meat Table;'920'
Column H:J - [Carbs(g)|Protein(g)|Fat(g)]x Column F - e.g;
Meat Table;'14'|'30'|'5'
My Goal: I want to be able to create a button/macro that will search Column A for the given ingredient, before inputing a value into Column F. I had started creating a few buttons where they input values into a specific Cell in Column A, however, I will continually be adding more ingredients, and I want the Column A to be sorted alphabetically, which instantly throws off this set cell method as I add a new ingredient.
At the end of the day, I thought some combination of VLOOKUP and OFFSET could be used, but I just can't figure this one out - Youtube isn't enough, and here we are.
If any of this was unclear, I'm more than happy to provide further details!
Guy
excel vba excel-formula
First off, I've tried to do my research, but I'm so inexperienced I don't know what I don't know, and I don't know how to ask the right question. I'd imagine my whole issue is just not understanding the functionality of excel.
I'll start by explaining my story and goals - I'm open to trying a more efficient method!
TL;DR - I need to create some sort of column search function that offsets a value
My Story:
So, I am about to launch an online personal training business. One of my services is nutrition coaching, and I'll be creating weekly meal plans for clients. To create these meal plans I want to be able to create a 'preset meal' button that I can easily press to add a given preset to the meal plan. I've been operating inefficiently, where I manually enter the quantity of each ingredient each time. I have tables for the different food groups (meat, grains, dairy, fruit, veg, other), they will be set up like the following. In this example, one of the required ingredients is 2 slices of ham (see Column F);
This is the previously set up macro, it was selecting a given Cell, not finding the ingredient and inputing a value from an offset
Example of table now
Column A - Ingredient - e.g;
Meat Table;'pork_ham_slice'
Column B - Energy (kj) - e.g;
Meat Table;'460'
Column C:E - Carbs(g)|Protein(g)|Fat(g) - e.g;
Meat Table;'7'|'15'|'2.5'
Column F - Quantity - e.g; -
Meat Table;'2'
Column G - Energy (kj)x Column F - e.g;
Meat Table;'920'
Column H:J - [Carbs(g)|Protein(g)|Fat(g)]x Column F - e.g;
Meat Table;'14'|'30'|'5'
My Goal: I want to be able to create a button/macro that will search Column A for the given ingredient, before inputing a value into Column F. I had started creating a few buttons where they input values into a specific Cell in Column A, however, I will continually be adding more ingredients, and I want the Column A to be sorted alphabetically, which instantly throws off this set cell method as I add a new ingredient.
At the end of the day, I thought some combination of VLOOKUP and OFFSET could be used, but I just can't figure this one out - Youtube isn't enough, and here we are.
If any of this was unclear, I'm more than happy to provide further details!
Guy
excel vba excel-formula
excel vba excel-formula
edited Nov 20 '18 at 7:30
Pᴇʜ
22.8k62950
22.8k62950
asked Nov 20 '18 at 4:34
Guy LeggettGuy Leggett
62
62
Please show us your work sor far and your exact table structure - screenshots would be very helpful.
– Michal Rosa
Nov 20 '18 at 4:47
Please always include the code in your question and format it as code block. An image of your code is not helpful.
– Pᴇʜ
Nov 20 '18 at 7:27
1
You will find this very helpful in terms of speeding up your code by avoiding .Select.
– QHarr
Nov 20 '18 at 7:51
add a comment |
Please show us your work sor far and your exact table structure - screenshots would be very helpful.
– Michal Rosa
Nov 20 '18 at 4:47
Please always include the code in your question and format it as code block. An image of your code is not helpful.
– Pᴇʜ
Nov 20 '18 at 7:27
1
You will find this very helpful in terms of speeding up your code by avoiding .Select.
– QHarr
Nov 20 '18 at 7:51
Please show us your work sor far and your exact table structure - screenshots would be very helpful.
– Michal Rosa
Nov 20 '18 at 4:47
Please show us your work sor far and your exact table structure - screenshots would be very helpful.
– Michal Rosa
Nov 20 '18 at 4:47
Please always include the code in your question and format it as code block. An image of your code is not helpful.
– Pᴇʜ
Nov 20 '18 at 7:27
Please always include the code in your question and format it as code block. An image of your code is not helpful.
– Pᴇʜ
Nov 20 '18 at 7:27
1
1
You will find this very helpful in terms of speeding up your code by avoiding .Select.
– QHarr
Nov 20 '18 at 7:51
You will find this very helpful in terms of speeding up your code by avoiding .Select.
– QHarr
Nov 20 '18 at 7:51
add a comment |
1 Answer
1
active
oldest
votes
To give you an example how to find a specific value in a table:
Dim FoundIngredient As Range
Set FoundIngredient = Worksheets("MeatTable").Range("A:A").Find(What:="Pork_Ham_Slice", LookAt:=xlWhole)
If FoundIngredient Is Nothing Then
MsgBox "ingredient not found"
Exit Sub
Else
FoundIngredient.Offset(ColumnOffset:=5).Value = 2
End If
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386303%2fexcel-can-offset-use-a-corresponding-code-as-a-value-in-another-column%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
To give you an example how to find a specific value in a table:
Dim FoundIngredient As Range
Set FoundIngredient = Worksheets("MeatTable").Range("A:A").Find(What:="Pork_Ham_Slice", LookAt:=xlWhole)
If FoundIngredient Is Nothing Then
MsgBox "ingredient not found"
Exit Sub
Else
FoundIngredient.Offset(ColumnOffset:=5).Value = 2
End If
add a comment |
To give you an example how to find a specific value in a table:
Dim FoundIngredient As Range
Set FoundIngredient = Worksheets("MeatTable").Range("A:A").Find(What:="Pork_Ham_Slice", LookAt:=xlWhole)
If FoundIngredient Is Nothing Then
MsgBox "ingredient not found"
Exit Sub
Else
FoundIngredient.Offset(ColumnOffset:=5).Value = 2
End If
add a comment |
To give you an example how to find a specific value in a table:
Dim FoundIngredient As Range
Set FoundIngredient = Worksheets("MeatTable").Range("A:A").Find(What:="Pork_Ham_Slice", LookAt:=xlWhole)
If FoundIngredient Is Nothing Then
MsgBox "ingredient not found"
Exit Sub
Else
FoundIngredient.Offset(ColumnOffset:=5).Value = 2
End If
To give you an example how to find a specific value in a table:
Dim FoundIngredient As Range
Set FoundIngredient = Worksheets("MeatTable").Range("A:A").Find(What:="Pork_Ham_Slice", LookAt:=xlWhole)
If FoundIngredient Is Nothing Then
MsgBox "ingredient not found"
Exit Sub
Else
FoundIngredient.Offset(ColumnOffset:=5).Value = 2
End If
answered Nov 20 '18 at 7:38
PᴇʜPᴇʜ
22.8k62950
22.8k62950
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386303%2fexcel-can-offset-use-a-corresponding-code-as-a-value-in-another-column%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Please show us your work sor far and your exact table structure - screenshots would be very helpful.
– Michal Rosa
Nov 20 '18 at 4:47
Please always include the code in your question and format it as code block. An image of your code is not helpful.
– Pᴇʜ
Nov 20 '18 at 7:27
1
You will find this very helpful in terms of speeding up your code by avoiding .Select.
– QHarr
Nov 20 '18 at 7:51