ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Macro Help (https://www.excelbanter.com/excel-programming/408790-excel-macro-help.html)

RemyMaza

Excel Macro Help
 
I'm trying to make sure I'm headed down the right path before I spend
a ton of time for nothing, so any feedback is very much appreciated.

Here's what I would like to happen within my excel worksheet. I will
have two manual inputs that will relate to an end result in another
cell. For instance, if I put a 1 in A1 and put a 22 in B1, I would
need C1 to display a result based on a cell block's input. So A1+B1 =
E1 but displayed in C1. I'm not sure if I should use a formula to
derive my result or write a macro because my variables seem to be of a
large number. For A1 I would have 3 variables and for B1 I would have
42 variables. What would be the best way to accomplish this task? If
then statements or something else? I'm open to any ideas.

Thanks in advance,

Matt

JLGWhiz

Excel Macro Help
 
For B1 do you have 42 variables or a variable with 42 possible values? Makes
a big difference.

"RemyMaza" wrote:

I'm trying to make sure I'm headed down the right path before I spend
a ton of time for nothing, so any feedback is very much appreciated.

Here's what I would like to happen within my excel worksheet. I will
have two manual inputs that will relate to an end result in another
cell. For instance, if I put a 1 in A1 and put a 22 in B1, I would
need C1 to display a result based on a cell block's input. So A1+B1 =
E1 but displayed in C1. I'm not sure if I should use a formula to
derive my result or write a macro because my variables seem to be of a
large number. For A1 I would have 3 variables and for B1 I would have
42 variables. What would be the best way to accomplish this task? If
then statements or something else? I'm open to any ideas.

Thanks in advance,

Matt


RemyMaza

Excel Macro Help
 
On Apr 3, 6:45*pm, JLGWhiz wrote:
For B1 do you have 42 variables or a variable with 42 possible values? *Makes
a big difference.



Here's the breakdown:
C2 - 3 variables
D2 - 42 variables

So it looks like 3*42... Each variable in C2 has 42 variables.

I need to input C2 and D2 and come up with a value in another cell
based on those variables... Here's what I have so far, but I can't
get past the first variable in A1... I mean if I put a 1 in A1, it
works fine, but I need the formula to continue if A1 equal 2 or 3...
The working code I have so far is:

=IF(C2=$K$1,VLOOKUP(D2,J2:K43,2,FALSE))

To make is simple K1 on this formula is only a number above my array.
This way I know which array I'm dealing with. If there is a more
efficient way, I'm not binded to this formula. I have 3 total arrays
that I need to lookup based on the first input i.e. =IF(C2= So if C2
equals something other than 1 it will lookup in a different array.
The formula above works great but when I try to expand it to the three
arrays, I end up with a formula that looks like:

=IF(C2=$K
$1,VLOOKUP(D2,J2:K43,2,FALSE)*IF(C2=O1,VLOOKUP(D2, N2:O43,2,FALSE)*IF(C2=S1,VLOOKUP(R2:S43,2,FALSE))) )

This sadly doesn't work in excel and I'm not sure how to fix the
formula to look past the first variable if it changes.
Thanks for any help...

Matt

RemyMaza

Excel Macro Help
 
On Apr 3, 8:09*pm, RemyMaza wrote:
On Apr 3, 6:45*pm, JLGWhiz wrote:

For B1 do you have 42 variables or a variable with 42 possible values? *Makes
a big difference.


Here's the breakdown:
C2 - 3 variables
D2 - 42 variables

So it looks like 3*42... *Each variable in C2 has 42 variables.

I need to input C2 and D2 and come up with a value in another cell
based on those variables... *Here's what I have so far, but I can't
get past the first variable in A1... I mean if I put a 1 in A1, it
works fine, but I need the formula to continue if A1 equal 2 or 3...
The working code I have so far is:

=IF(C2=$K$1,VLOOKUP(D2,J2:K43,2,FALSE))

To make is simple K1 on this formula is only a number above my array.
This way I know which array I'm dealing with. *If there is a more
efficient way, I'm not binded to this formula. *I have 3 total arrays
that I need to lookup based on the first input i.e. =IF(C2= *So if C2
equals something other than 1 it will lookup in a different array.
The formula above works great but when I try to expand it to the three
arrays, I end up with a formula that looks like:

=IF(C2=$K
$1,VLOOKUP(D2,J2:K43,2,FALSE)*IF(C2=O1,VLOOKUP(D2, N2:O43,2,FALSE)*IF(C2=S1,*VLOOKUP(R2:S43,2,FALSE)) ))

This sadly doesn't work in excel and I'm not sure how to fix the
formula to look past the first variable if it changes.
Thanks for any help...

Matt


I just scrapped the 3 array approach. I took C2 input and added a
number to it that would offset it farther down the array. I combined
all three arrays into one, so with this new input it would look
throughout 1 array but farther down if C2 = 2 or if C2 = 3.... Worked
like a charm...


All times are GMT +1. The time now is 11:15 PM.

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