As the title implies, I'm trying to have column C tell me all of the results of A in which the corresponding B value is a "1" for example.
So if this was my data set:
a 0
b 1
c 0
d 1
e 0
f 1
g 0
Then anytime we see a 1 for example from B1:B6, I want it to show A1:A6
Using If=(B1=1,A1, ) for each row, I get a result such as this:
a0
b1b
c0
d1d
e0
f1f
g0
However, I'm hoping to avoid the spaces between the rows for the third column as Ultimately I'm putting this on a different tab of the worksheet, meaning I was hoping for it to look like:
a0b
b1d
c0f
d1
e0
f1
g0
Using If=(B1:B6=1,A1=A6, ) I was able to get it to show just a single result of just b, but again that doesn't show me d or f in the neat little column I'm hoping for. I tried to just sort it afterwards based on alphabetical afterwards using the first formula, but this works for about 1/4 second before it unsorts itself.
I apologize if this type of question has been answered before, I didn't see anything, but then again with my relative lack of experience with excel I could have skipped right over it because I'm not familiar with the jargon. Oh and just to clarify, I don't need help putting it on a different tab. That's at least one thing I know how to do. I also hope the columns make sense, the formatting kept changing so I had to change it up a bit, and I can't post pics until 10 reputation. Thanks!
Unless I am missing something from your question, the answer to this is fairly simple.
I assume you are starting with this:
And you would like to get to this:
If so, the formula in Cell C1 should be:
=IF(B1=1,A1,"")
You can then use the fill handle to replicate this down as far as you require.
My only other interpretation is that you would like the outcome to be this:
If so, then the formulae in Cell C1 should be:
=IF(B1=1,A1 & B1 & A1,"")
Then again use the Fill handle to replicate the formula down as far as required.
Related
I am wondering if there is a way to do what I want more automatically, i've been doing it with good old regular copy paste but it's taking a lot of time, I need to take the horizontal data I have currently and put it vertically while keeping the first column for each rows, the first column is my "main" part number and I need to link all the other numbers starting from column B to this main part number, example below,
I sometimes have hundreds of rows and columns to do this for, here is what i'm working with
[1]: https://i.stack.imgur.com/dIyZv.png
And here's what the end result needs to look like;
[2]: https://i.stack.imgur.com/PvxGh.png
Thank you in advance!
It can be achieved either with VBA Code or with formulas. I did it with formulas and will try to show you how below.
I have one sheet with all the data, lets call it Sheet1. It looks like this:
Then, I have another sheet which returns what you want (Sheet2). It looks as follows:
Note that the first two columns are necesary for the formulas to work. The actual result is on Columns C and D.
Now, below are the formulas (or values) you would need to put in Sheet2 to make it work:
Cell A1: 0
Cell B1: 1
Cell A2: IF(B2=1,A1+1,A1)
Cell B2: IF(B1+1=$G$1,1,B1+1)
Cell C1: OFFSET(Sheet1!$A$1,A1,0)
Cell D1: OFFSET(Sheet1!$A$1,A1,B1)
Cell G1: The number of columns in the data on Sheet1
Then, just drag the formulas (not the values in A1, B1), until you have the expected result.
I would suggest you try to implement this simple example first, and then move it to your actual spreadsheet.
Let me know how it goes.
EDIT: Regarding your comment, we could do a trick to make it work for a variable number of columns.
First, lets add some variability to the number of columns in Sheet1. This is how my new Sheet1 looks like:
On Sheet2 I added a formula to count the number of columns per row. See Column F below:
Then, the trick is to change the formulas in Column B in Sheet2:
Before: Cell B2: IF(B1+1=$G$1,1,B1+1)
After: Cell B2: IF(B1+1=OFFSET($F$4,A1,0),1,B1+1)
Note: My formula to count the number of columns per row is:
Cell F4: COUNTA(Sheet1!A1:D1)
Note: Change D1 to the max column in Sheet1. Eg. M1.
Note2: You can get rid of cell G1 now.
Start with column B and everything else becomes a doddle. I only use 1 formula for column B and no more than 1 or 2 for column A (there are 3-4+ methods, no need to duplicate yourself but choose any of them to construct A).
I'm only using 1 formula to make each column. Entire job task done in a minute-5.
Column B. Do this first for all your "column B's":'
=IF(ROW(A1)=1,INDEX(A$1:T$1,INT(((ROW()-20)/20+1-ROW($A$1))/COLUMNS(A$1:T$1))+1,MOD(ROW()-20-ROW($A$1),COLUMNS(A$1:T$1))+1),INDEX(A$1:T$1,INT(((ROW()-20)/20+1-ROW($A$1))/COLUMNS(A$1:T$1))+1,MOD(ROW()-20-ROW($A$1),COLUMNS(A$1:T$1))+1))
So all you have to do is drag down. Change only the row references to refer to your 100's if different rows you need to do this for. 1 minute. Job done
for 30 columns/cells change T to AD, for 200 cells , change T to GR, etc. You can also force it to stop at number of your choice.
If you put it anywhere else, it will still work, but your going to have to jiggy with the math a bit to get it to start from the the first entry in the row ( or the specific Wherever you want). Its up to you.
It acts like a modular clock. Been using it for a few years. Ticker tape. Rolling slabs of concrete laying out for you.
here, this is what I get when I plug it into the first row of any column , referring to a 20 field length header on my sheet.
Etc... It continues forever (or for however long you want it). (and you can change the mod anytime).
The first argument you could change to whatever your requirements are , for instance , if(LEN(F8)<1, or whatever, to Start/"Set the clock."
And For any corresponding ranges (your first column for each) (** Your "Column A's" **):
=IF(LEN(H20)<1,K21,H20)
or you can use this logic. It Becomes elementary.
=IF(J21=K21,J21,J20)
Better if you use this starting from row 2 on each column A: if(and(j1=it's next door neighbour, row(it's next door neighbour cell=1)), it's self j1,.. blah blah blah blah
OR AM I MISSING THE POINT ?
Method for getting column A;
Since you already have B, A becomes a simple trivial matter. Like cell =$fixed$cell , i.e. A1=$B$1 and drag down.
simple. headache over. game over. Its all effortless.
But if you want me to elaborate more ,
method 2 for getting 1st column, column A's;
=IF(LEN(AV1)>1,IF(ROW(AV1)=1,AV1,INDIRECT("Av"&1)),"")
=IF(ROW(B1)=1,B1,INDIRECT("B"&1)) <---- drag down from row 1
Method 1 for getting 1st column;
=IF(LEN(AV1)>1,$AV$1,"") <----- drag down from row 1
Method 3, below was my favourite:
=$B$1 <---- from row1 drag down (where row1 was just = column B, cell b1, a1=b1) easy peasy .
You could always demand a further simplification of M3:
A1=if(len(b1)>1,$b$1,"") <--drag down from b2 (where b1 was already set) *probably best because only returns a value as long as column B is .otherwise returns blank.
It's like handling duplicates by formula. Similar .
there was a method 4 too. bUt its late. (Written # 02:00)
Or did I miss the point? It's easy. Imo
Im only using 2 formulas. 1 for each column you need done . do column B first, and colimn A becomes a matter of fact . A doddle.
method 1 is my new favourite.
Its late, my naighbours have pissed me off again. Pardon my fonts and writing but seriously. didnt expect this. some people need to go to jail.(my naighbours)
So in the end: 1 formula for B. 1 for A (any one of any the 4+ methods. There are more also) , plug in and scroll for all the rows you need this done for . takes you 30 seconds? 5 minutes tops for all your rows.
At first thanks to answer)) (It's important for me :p )
I have a number in A3.
When there is this number in column A (Sheet1), per exemple A7 then it will take the value of the cell B7.
=SOMMEPROD(('Sheet1'!A3:A34=Sheet1!A3)*('Sheet1'!B3:B34))
I use SOMMEPROD, it's working but only with number, and sometimes I have text and number in my cell (column B).
I already changed the format of the cell but doesn't work.
Thanks a lot)))
I think you are saying that some of the values in column B are expressed as text, not as a number, probably because they were imported from another source.
if that is the case: First, convert column B into numbers, Then, use sumproduct.
For example, FIRST convert text to values:
in C3 you would enter
=value(b3)
Then copy that down to from C3 to C34.
Then
=SOMMEPROD(('Sheet1'!A3:A34=Sheet1!A3)*('Sheet1'!C3:C34))
should have the desired effect.
Note that you sometime get #N/A errors with the "value" function, for example if there are unexpected spaces. To be safe, rather than using value alone, try this:
= iferror(value(B3),0)
or to be more creative you can try:
= iferror(value(substitute(B3," ","")),0) ' deletes all spaces
= iferror(value(substitute(substitute(b3,char(160),"")," ","")),0)
'deletes all spaces and "nonbreaking spaces" copied from a web page
It depends on what you're trying to use SumProduct for. There's two main reasons this function shows up. Those are:
To sum the product of two ranges.
To sum a range of numbers that meet multiple criteria. This relies on that True = 1 and False = 0 so when want to find the combined weight of blue dogs in some cells, your formula might look like =SUMPRODUCT(1*($A$1:$A$50 = "Blue"), 1*($B$1:$B$50 = "Dog"), $C$1:$C$50). Note the 1* which guarantees the formula will know how to multiply the results. After all, True and False don't multiply. Their binary representations (1 and 0) though, do.
NB though that people also sometimes remember it as a lookup formula because of the second use, and therefore expect to be able to get text back. Such approaches are an easy misunderstanding to end up with, but really there you want to use an INDEX(<Result Array>,MATCH(1,INDEX(1 * (FIRST CONDITION) * (SECOND CONDITION) * (AND SO ON),,),0). This approach basically gives you an array formula without CTRL-SHIFT-ENTER (it's not faster, but because the condition is in an index formula, it works), and your conditions can be arbitrary (the same way as for sumproduct). But it'll give you the FIRST result, not the sum of all of them.
Hope that helps.
Edit: Crossed my mind, you might be expecting A1 to contain Erp and B1 to contain 54, and in C1 you want Erp54. This doesn't even need a function - just the & operator, which joins two strings together - so in C1, you'd just put =A1 & B1. And you're done.
If my L8 cell has TEST and my L9 has
ABCDEFG</div>RED
and I am trying to get
ABCDEFGTEST</div>RED
as a result I am using:
=CONCATENATE(LEFT(L9,SEARCH("G</div>",L9))&L8&RIGHT(L9,SEARCH("</div>",L9)))
But my actual result looks like:
ABCDEFGTEST/div>RED
How do i fix this? so, I dont lose the < on my end dig tag?
Edit: rewrote with simplified example to hopefully be more clear
Edit2: concatenate example
Try this formula to get ABCDEFGTEST</div>RED
=REPLACE(L9,FIND("<",L9),0,L8)
combine Concatenate with the Left, Mid, Right (to get a partial string) and the Find and Len (to see where this "middle" is either by finding a specific string or a location) functions.
I'm not entirely sure what your question is; I agree with #Mowgli.
Having said that, I'm going to take a stab.
If you're trying to insert column C in the middle of column B, I would move the URL & img to separate columns (for the same of argument, let's make them K & L(as K_B states, you can use FIND to do this.)
Then I'd make column Z1 = "&C1&"
Column B
ABC
Column C
123
Formula
=LEFT(B3,2)&C3&RIGHT(B3,1)
Good morning. I have been searching for some code either a formula or VBA to lookup values in a table. I have two tables that I am looking to migrate data from the old with the new. Both tables are relatively the same.
A B C D E
1 Store 1234 2345 3456 4567
2 1234 0 5 10 15
3 2345 5 0 20 25
4 3456 10 20 0 35
5 4567 15 25 35 0
It is basically a mileage table with location to location distance. I am looking for a way to take the values from the old table into the new when the row columns dont match up exactly due to new locations added.
I know how to do a vlookup, but that dosent do what Im looking for... I want a way for a formula or vba to something like "find Value in B2 "1234" where it intersects the value in D1 "2345" = D2 "5"
Should be able to do a Index and Match combo to find it. I1 = From, K1 = To you can just type in the locations into those cells and get the range out you want.
=INDEX(A1:E5, MATCH(I1,A1:E1,0), MATCH(K1,A1:A5,0))
Can you implement IF formula to vlookup? In abstract: =IF((vlookup)=something),do this, else)
I would be hapy to look into this issue further, if you could provide complete BEFORE data and expected AFTER data.
Also, maybe =DGET would work for you?
I used this formula slightly modified and it worked fine,
=INDEX($A$1:$G$7, MATCH(B12,$A$1:$A$7,0), MATCH(C12,$A$1:$G$1,0))
the first part of the equation is the entire table including the X and Y coords. the next two parts are the X and Y coords (you can swap these round if you wish)
so the requested information for x and y was put in cells C12 and B12 and all those cells below...
then I used the dollar symbol to fix all the other look up cells, so i could use auto fill, and entered this in E12 (this is where the result will appear.
You can see the table in the attached (or could if I was allowed to attach it). I am looking up B12 (3) in column A then looking up C12 (6) in row 1 and returning the value at the intersection (in this case returns "r").
or there would be an attachment if the stupid web page did not insist on having me obtain a 10 reputation... hopefully you get the idea...
So I have a sheet similar to this:
A B C D E F
1 Name Age Number Gender Player player No.
2 Droid12 11 M Droid12 F3
3 R2D2 13 M C3P0 F12
4 C3P0 12 F Bot13 Y7
5 YVH7707 11 F J34 Z2
6 Bot13 15 M
7 Slim33 13 F
8 ABot43 14 F
9 DBo11 11 M
10 J34 12 M
I am trying to fill in Column C with the player number, if the person in question has one (Imagine that the sheet is thousands of time this large).
I have the following VLookup function in each cell in C (copied down from C1, of course):
=VLOOKUP(A2, $E$2:$F$5, 2,FALSE)
And am getting the result:
#N/A
When I try to step through, I get the error
Sheet1!$A$2 = Droid12: The cell currently being evaluated contains a
constant
Anyone have an idea what I'm doing wrong?
Thank you!
EDIT
I've tried some of these fixes, with no positive results. I tried this in C1-C3:
C2 contains:
=IF(A2=E2, F2, FALSE)
With the result that cell C2 contains the value Droid12
C3 contains:
=VLOOKUP(A2, $E$2:$F$3, 2, FALSE)
and is getting a #N/A error (with the same error:
Sheet1!$A$2 = Droid12: The cell currently being evaluated contains a
constant
The values are all standardized (Trimmed,etc...), and there is definitely a match in the range I'm comparing to, so I really can't see what I'm doing wrong. Anyone ever experience this before?
edit 2
I fixed it, turns out I had Player No. In column E and Player in Column F, so the comparison for some reason was not running correctly. I switched those two entities around, and the VLOOKUP worked fine. Weird, but I'm not complaining. Thanks to everyone who tried to help!
Usually it happens if there is no exact match. Try to use trim and wildcard chars to allow matching to skip spaces. For example:
=VLOOKUP(CONCATENATE("*",TRIM(A2),"*"), $E$2:$F$5, 2,FALSE)
Use this formula:-
=IF(ISERROR(VLOOKUP(A2,E:F,2,FALSE)), "",VLOOKUP(A2,E:F,2,FALSE))
In Simple, formula is
=VLOOKUP(A2,E:F,2,FALSE)
Issue is caused due to the Range, which is mentioned as $E$2:$F$5.
When you are trying to drag the formula for the rest of cells, Range is getting updated wrongly. This is causing issue.
The Cell which doesn't match the actual value then VLOOKUP returns #N/A. To overcome this, I have placed a IF condition to check any error and display empty if fails otherwise the value.
Sometimes the constant error can be avoided if you have the reference data on the furtherest left-hand column on all sheets.
i.e.
Column A1 = Description plus info A2:etc (Sheet 1 and Sheet 2)
The N/A is the result of the name you are looking up not being in the list. This is normal behavior for the VLOOKUP function.
To eliminate the NA being displayed try this formula:
=IF(ISNA(VLOOKUP(A2,$E$2:$F$5, 2, FALSE)),"",VLOOKUP(A2,$E$2:$F$5, 2, FALSE))
This checks to see if the result of the lookup is N/A. If it is, then display blank (""). If the result is not NA then display the lookup value.
One issue with this solution is the lookup will be performed twice on each record that is found (once to check if it is N/A and once again to display the value (although Excel may be optimizing for this situation).