Excel selective increment - excel

Hi I'm trying to write a script in excel that returns a correlating job serial number (which resides on a different sheet) when a cell is filled with the job name.
=IF(D5="Misc",Jobs!A2,IF(D5=1715,Jobs!A3,IF(D5=1725,Jobs!A4,IF(D5=5640,Jobs!A5,IF(D5=6121,Jobs!A7,IF(D5=6150,Jobs!A8,IF(D5="6161-IDC",Jobs!A10,IF(D5="6161-JM",Jobs!A11,IF(D5=6161,Jobs!A12,IF(D5=6535,Jobs!A14,IF(D5="Hudson",Jobs!A14,IF(D5="Berendo",Jobs!A15,IF(D5="Berendo-Move",Jobs!A16,IF(D5="Bungalos",Jobs!A17,IF(D5="Bungalo",Jobs!A17,IF(D5="Camarillo",Jobs!A18,IF(D5="Indio",Jobs!A19,IF(D5="Lillian",Jobs!A20,IF(D5="6161-Beam",Jobs!A21,IF(D5="6161-Roof",Jobs!A22))))))))))))))))))))
The above script does what I need it to do, the problem is I need it copied to 30+ rows with ONLY the "D5" value incrementing. When I hover in the cell corner and drag down to new cells it increments other references besides the "D5" value.
I did a search and replace and manually copied the script to each of the 30 cells to get it functional for now but I'm going to have to do that every time I add a job. I'd like to just add the new job condition and use the fill handle to drag it to all cells, I feel like I need an escape character though to limit what cells are being incremented, I'm just not sure what that would be (it's always going to be column "D", I just need the row incremented to "d6, d7," etc)- thank you in advance for your help!

Seems a case sensitive replacement of A$ for A may be adequate:
=IF(D5="Misc",Jobs!A$2,IF(D5=1715,Jobs!A$3,IF(D5=1725,Jobs!A$4,IF(D5=5640,Jobs!A$5,IF(D5=6121,Jobs!A$7,IF(D5=6150,Jobs!A$8,IF(D5="6161-IDC",Jobs!A$10,IF(D5="6161-JM",Jobs!A$11,IF(D5=6161,Jobs!A$12,IF(D5=6535,Jobs!A$14,IF(D5="Hudson",Jobs!A$14,IF(D5="Berendo",Jobs!A$15,IF(D5="Berendo-Move",Jobs!A$16,IF(D5="Bungalos",Jobs!A$17,IF(D5="Bungalo",Jobs!A$17,IF(D5="Camarillo",Jobs!A$18,IF(D5="Indio",Jobs!A$19,IF(D5="Lillian",Jobs!A$20,IF(D5="6161-Beam",Jobs!A$21,IF(D5="6161-Roof",Jobs!A$22))))))))))))))))))))

Related

Excel multiple running totals

I'm trying to make a simple formula for multiple running totals.
Basically, it's for recording transactions for different accounts, showing the running total of that particular account for each row. So, it's impossible to use SCAN+LAMBDA function. One way to do it is to have a set of helper arrays somewhere, but here I'm using another way, by using XLOOKUP.
=C2+XLOOKUP(D2,D$1:OFFSET(D2,-1,),E$1:OFFSET(E2,-1,),0,,-1)
Basically, it looks up the last account balance above the current row of the corresponding account and add the current transaction amounnt to it. It works by draggin down to all the transaction rows.
Since the number of transactions is over 10 thousand, I was trying to minimize the file size by using named function with LAMBDA.
Name: AddtoBalance
=LAMBDA(c,c+XLOOKUP(OFFSET(c,,1),Sheet1!E$1:OFFSET(c,-1,1),Sheet1!F$1:OFFSET(c,-1,2),0,,-1))
And changed cell E2 to
=AddtoBalance(C2)
and dragged it down to all transaction rows.
However, after saving and re-opening, the cells are having errors. I have to go to Name Manager, click Edit but without doing anything and Close it. Then the cells becomes fine again. It seems to me that when re-opening a workbook, the formulas are not calculated sequentially from top to bottom. Is that right? Is there any options to change it?
I think you are going to hate me when you see this…
Put this in E2:
=SUMIF( B$2:B2, B2, C$2:C2 )
Then copy it down. Mind the dollar signs, they are important. You could place this in a named Lambda but the character count reduction is probably immaterial.
After rebooting and restarting excel, actually I could not reproduce the error. It works fine with the Lambda function now.
Whole different approach, but how about:
=LET(f,ISNUMBER(C:C),
c,FILTER(C:C,f),
d,FILTER(D:D,f),
s,SEQUENCE(COUNTA(d)),
MMULT(
(d=TRANSPOSE(d))*(s>=TRANSPOSE(s)),
c))
It first creates an array of TRUE's and FALSE's on column C:C if it contains a number. This is used to filter the values to be used from column C and D.
A sequence of the count of filtered values in column C is used to simulate it's row number in that filtered range.
Now MMULT checks row by row how many values of column D equal it's current value where the sequence number for that "row" is smaller or equal than the current.

Go down a column until a certain cell and then select a cell to the right

Trying to automate a task using VBA but am very beginner with it.
I'm trying to select column x, go down that column until it says a certain value, and then select the cell that is one to the right of the cell that contains that value. IE go down column x until it says "apple" and then select the number to the right of the cell containing "apple"
After this, I want to go to the next sheet and perform the same action. I know I need to perform some type of loop but mostly confused about how to go down a column until a certain cell and then to the right.
You want to increase the range. This thread should be helpful to you.
https://answers.microsoft.com/en-us/msoffice/forum/all/vba-select-the-ranges-next-to-the-activecell/80a080aa-6355-4700-9574-83197190164a
**FYI Need to include specific code you have tried to use to resolve and specific errors if there are any. You will get less responses if you have a 'lame' question (i.e. just hoping someone else to do it for you)

Need a blank cell when IF cell is blank

Long time listener, first time caller...
I'm sure this is simple, but I don't know how to do it.
I am putting together a very simple spreadsheet that will autopopulate the correct shift when a manager is input into a cell. I need to do this cell by cell, because some of the managers overlap shifts.
In place of "name" and "shift" I have the actual manager and shift, but for simplicity sake I have:
=IF(K21="NAME", "SHIFT1", "SHIFT2")
and that works just fine for this because there are only 2 managers with different shifts.
However, when there are no manager names in K21, it still gives me a shift in the other cell.
How do I leave that blank until the manager name is filled in?
(I will also need to have several other "IF" statements in other cells, as there are more managers on those shifts, and nested IF statements are telling me there are too many arguments. Not sure what I'm doing wrong.)
Try using your IF as the second argument for another IF that would check if the Manager cell is empty:
=IF(ISBLANK(K21),"",IF(K21="NAME","SHIFT1","SHIFT2"))
However I would just go with vlookup() like this:
=IFERROR(VLOOKUP(K21,$Q$20:$R$21,2,0),"Not in list")
and then you can have a list of names and shifts and even add a 3rd column with weekend shifts...
So trap the blank first:
=if(k21="","",your if here)
But if k21 has other text then you may need to consider something else, perhaps a list of valid names:
=if(iferror(vlookup(k21,list,1,0),0)>=1,your if here,"")
That list can be a range of cells or just both the names.
See:
=IF(IFERROR(VLOOKUP(K21,Q20:Q21,1,0),0)>=1,IF(K21="Fred","SHIFT1",IF(K21="Julie","SHIFT2","Error1")),"Not in List")
Since you mentioned you'll have multiple if statements, you might consider doing a table and then a lookup. Here's a simple example based on the idea of you have your managers and shifts in column a and b and you type the managers name in cell D2 (or K21 in your case). This would also account for a for blank entry compared to a WRONG entry......
=IF(ISBLANK(D2),"",IFERROR(VLOOKUP(D2,A:B,2,FALSE),"Not listed!"))

Automate concatenation process

Here I am stucked with one excel issue where i want to concatenate from column F till column I where the logic is when the benchmark column A3 (for example) is blank it need to concatenate column F till column I till there is a value at column A4.and this logic need to automatically concatenate the mentioned column till there is a value under the benchmark column. currently i need to keep change the concatenate range in order to concatenate it fully with the logic. Appreciate if anyone can help me out.
Below image shows how i am doing manually which very time consuming
You can use the MATCH function (with a wildcard) to find the next non-blank row; and use that in an INDEX function to detect the range to concatenate.
Assuming your data starts in A3 and the lowest possible row is row 1000 (change the 1000's in the formula below if it might be much different:
J2: =IF(A2="","",CONCAT(INDEX(F2:$I$1000,1,0):INDEX(F2:$I$1000,IFERROR(MATCH("*",A3:$A$1000,0),1000-ROW()),0)))
Note: It is possible to also develop solutions using INDIRECT and/or OFFSET. Unfortunately, these functions are volatile, which means they recalculate anytime anything changes on your worksheet. If there are a number of formulas using these functions, worksheet performance will be impaired. INDEX and MATCH are non-volatile (except in ancient versions of Excel - pre-2003 or so)
The OFFSET-function would come on handy here. One solution is to do it like
This works in my worksheet.
Cell Q6 just defines the number of rows downwards that the MATCH-function is checking for the next "HEADER1" value. If "HEADER1" is found, the MATCH-function returns how many rows down-1. If no "HEADER1"-value is found within that range, that value is then the number of rows used.
If the first column also has "HEADER2" and so on, you can add the MID-function to both references inside MATCH to limit which part of the string are to be searched for.
I tried to adjust the references properly to fit your sheet, but I may have missed something:
=IF(ISBLANK($B2),"",CONCAT(OFFSET($B2,0,0,IFNA(MATCH(MID($B2,1,6),MID(OFFSET($B2,1,0,$B$1),1,6),0),$B$1),4)))

How to calculate the number of times a particular letter is typed on a cell in Excel?

I know the title looks enormous but I don't know how to put the title to the question I want to ask.
Ok, basically this is what I have so far:
On the spreadsheet I a column asking a question and the you fill up the row and according what you have there you have to put a Y (yes) or N (no).
On the end of the month we need to know how many Y (yes) we have, I need to do this manually. I was wondering, if there is a way to use a separate cell to count how many Y's we have on that column?
If someone could help on that I will very much appreciate.
This is completely possible. Depending upon which version of Excel you're using (2007 and later should work), try pressing Functions, and then choose AddCount, which counts the amount of something in a certain space.
If this does not work for you, you can also create drop-down menus inside of the Data Validation feature of Excel.
If you're making a form these two options will work.
If you have a column (say column A) containing either Y or N, then in a cell outside that column enter:
=COUNTIF(A:A,"y")
This will perform the counting and will count either upper case or lower case letters.
Select the excel cell where you want the output. Then go to function box and type =COUNTIF(CL1:CL100,"Y")
where CL1 is your stating column Index and
CL100 is your last column index till where you want to search.

Resources