Closing row gaps in excel - excel

I have the following in an excel spreadsheet:
A B C
1 ID Label Text
2 123 R Some text
3
4 456 S Some more text
5
6 789 R Even more text
But I want to close the row gaps so my excel spreadsheet can look like the following
A B C
1 ID Label Text
2 123 R Some text
3 456 S Some more text
4 789 R Even more text
5
6
I found the following https://www.extendoffice.com/documents/excel/511-merge-rows-keep-data.html but it is not quite what I am looking for
Question: Is there an automated/easier way to close the row gaps, aside from doing this manually?
(I can do this manually by cutting and pasting but my excel sheet contains thousands of rows that contain these sort of row gaps)

You could do an index match. In another column (say column D), simply do something like if(a3="", "", row()). Then in another column rank each row if there is a value. Something like if(d3="", "", rank(d3, $d$1:$d$6). Create another column (say column E) that just goes from 1 to the end of the data set (increment each row by 1). Finally do an index match like so: index(A:A, match(d3, $E:$E, 0).

Per Jeeped and tehhowch, the easiest way to accomplish the goal is to simply sort by column ID value

Related

How to find and replace from a List in Excel

Not using VBA but just simple excel, can anyone help me find a solution to this problem? Would greatly appreciate it!
I have a list of Names in Sheet 1 like below
-
A
1
sp_abc_Rick
2
sp_abc_Jabba_the
3
sp_abc_Dany
4
sp_random_Rick
5
sp_random_Jabba_the
6
sp_random_Dany
7
sp_constant
8
sp_ripley_art_Dany
9
sp_ripley_art_Jabba_the
10
sp_wakeup
I have a list of Mapping Table in Sheet 2 like below
-
A
B
1
Rick
Morty
2
Jabba_the
Hutt
3
Dany
Dragon
I wish to have a result in Sheet 1, in column B, like below
-
A
B
1
sp_abc_Rick
sp_abc_Morty
2
sp_abc_Jabba_the
sp_abc_Hutt
3
sp_abc_Dany
sp_abc_Dragon
4
sp_random_Rick
sp_random_Morty
5
sp_random_Jabba_the
sp_random_Hutt
6
sp_random_Dany
sp_random_Dragon
7
sp_constant
sp_constant
8
sp_ripley_art_Dany
sp_ripley_art_Dragon
9
sp_ripley_art_Jabba_the
sp_ripley_art_Hutt
10
sp_wakeup
sp_wakeup
To give you a context of the number of rows. Sheet 1 will be bigger with more than 1000 rows. Sheet 2 (Mapping Table) is constant set of rows. Currently it is about 100 rows.
You can use a formula like shown below using LOOKUP(), SEARCH() with SUBSTITUTE()
• Formula used in cell B1
=IFERROR(SUBSTITUTE(A1,LOOKUP(9^9,SEARCH($D$1:$D$3,A1),$D$1:$D$3),
LOOKUP(9^9,SEARCH($D$1:$D$3,A1),$E$1:$E$3)),A1)
There you go. There may have other better solution. This is what I got.
All in column B.
=IFERROR(CONCAT(MID(A1,1,MATCH(1,(CODE(MID(A1,ROW($Z$1:$Z$255),1))<90)*(CODE(MID(A1,ROW($Z$1:$Z$255),1))>=65),FALSE)-1),INDIRECT(CONCAT("sheet2!b", MATCH(MID(A1, MATCH(1,(CODE(MID(A1,ROW($Z$1:$Z$255),1))<90)*(CODE(MID(A1,ROW($Z$1:$Z$255),1))>=65),FALSE), LEN(A1)), Sheet2!$A$1:Sheet2!$A$300, 0)))),A1)
Break down is as follow;
Let's start put things from Column C onward.
Column C, to find the index of the first capital letter from the text.
ref: http://dailydoseofexcel.com/archives/2007/02/21/find-position-of-first-capital-letter-in-a-string/
=MATCH(1,(CODE(MID(A1,ROW($Z$1:$Z$255),1))<90)*(CODE(MID(A1,ROW($Z$1:$Z$255),1))>=65),FALSE)
Column D, cut the name part by using upper case letter index from column C, sp_abc_Jabba_the -> Jabba_the
=MID(A1, C1, LEN(A1))
Column E, search row number from Sheet2 by matching Column D's name with Sheet 2's Column A, this will get matching row number from Sheet2.
=MATCH(D1, Sheet2!$A$1:Sheet2!$A$300, 0)
Column F, get Sheet2's Column B value by the row number from Column E.
=INDIRECT(CONCAT("sheet2!b", E1))
Column G,
Cut "sp_abc_" from "sp_abc_Rick"
Concat "sp_abc_" with Column F's "Morty".
If there is any error, use Column A value as default.
. <- this dot is intentional. please ignore.
=IFERROR(CONCAT(MID(A1,1,C1-1),F1),A1)
Try:
Formula in B1:
=BYROW(A1:A10,LAMBDA(a,LET(b,TEXTBEFORE(a&"|","_"&A12:A14&"|",-1),IFERROR(CONCAT(IF(b&"_"&A12:A14=a,b&"_"&B12:B14,"")),a))))
The concatenation with a "|" would assert we only replace values when at the exact end of the input. Just in case there would be a stray (for example) 'Rick' somewhere before the end.

Lookup Function Excel

I am working on a lookup function and I cant seem to make it work. I am looking up a value from one worksheet into another. The issue I am having is that some names in the excel sheet iI am looking up are not spaced at the same as the other sheet.
For example instead of John Davis, the lookup sheet might have the name as JohnDavis. Or Peter Lee Thomas might be Peter LeeThomas. So my looking function is failing because of this.
=IF(B2="AD Non Chargeable","Internal",INDEX(Sheet3!B:B,MATCH('Raw Data'!B2,Sheet3!A:A,0)))
Can you please advice on the best way around this? My Lookup sheet is Sheet3
Okay, if for example your data looked like this:
A B C D
Some Text 1 2 SomeText3
Som e Text 2 3 Some Text 2
So meText 3 4 SomeTex t1
Lookup formula in column D would be:
=INDEX($B$1:$B$3,MATCH(SUBSTITUTE(C1," ",""),SUBSTITUTE($A$1:$A$3," ",""),0))
Make sure to apply this formula with Ctrl + Shift + Enter.
The result will look as expected:
A B C D
Some Text 1 2 SomeText3 4
Som e Text 2 3 Some Text 2 3
So meText 3 4 SomeTex t1 2
One solution would be to create another column Sheet3, in this example B, to remove all spaces, like this:
In cell B2 (and copied down): =substitute(A2,"","")
Then alter your lookup to alter its data similarly and to search in this space eliminated row B:
=IF(B2="AD Non Chargeable","Internal",INDEX(Sheet3!B:B,MATCH(substitute('Raw Data'!B2," ",""),Sheet3!A:A,0)))

Excel Arrange multiple Columns

I have a data like this in excel:
1 1
1 2
2 2
3 2
And I want the result to be displayed like this:
1
1
1
2
2
2
2
3
Its like a ascending sorting. If the number in columnA <= columnB, it will be display first, at the same time, columnB will have a empty cell or blank value.
I have looked for this for a while but no one has the problem like this.
I would prefer a formula rather than VBA code.
Please advise, thanks!
Edit: I hope this explanation will be easier to understand
Data (A1:B2) - Result (C1:D4). Each number in Data (A1:B2) is a result of complicated formula so I cannot change its position
A B C D
1 1 2 1
2 3 4 2
3 3
4 4
Honestly, if you want to avoid VBA, here's a manual process that would give you the results you want:
Color each column (ie. Column A Red and Column B Blue)
Place values of column B under column A
Sort & Filter by Sort Smallest to Largest
Copy the contents of column A to column B
Last for Column A Find and Replace all* with format Blue then do the same for column B only with format Red. (See below for more info on how to do that).
Following those steps isn't the most conventional, but it will give you the results you wanted without VBA.
*Find and Replace based on font color:
1. Press Ctrl-H
2. Click Options
3. Click Format > Font > then select your font color > OK
4. With the Find What blank with the font color and the Replace With blank click Replace All.

Find duplicates with a suffix in excel and keep results

I have a spreadsheet with a list of items in one column (A) and in column C shows the total sold. I'm trying to find all the items within column A.
The issue is, some items are the same, only they have a suffix, mostly separated by a -. The values in column C would be different as well.
Example:
ABC = 5
ABC-123 = 3
ABC-543 = 2
I'm looking to identify only 123 and then combine all the values, so that it will show ABC and 10 as the total.
I've looked around how to remove the duplicate suffix, but have so far failed to find a method when trying to add the total values.
Many thanks
do you mean the data you have looks like this:
column A column B column C
ABC 5
ABC-123 3
ABC-543 2
if so, you can select column A then go to data then text to columns then delimited select other by putting - sign, next and finish.
result must be:
column A column B column C
ABC 5
ABC 123 3
ABC 543 2
then you can =sumifs(C:C;A:A;"ABC") (keep in mind that column B must be empty)
if you have ABC-123 = 3 in the same cell as a text, then you can do:
=IF(SEARCH("ABC";F3);RIGHT(F3;LEN(F3)-FIND("=";F3)-1);"")
where F3 is equal to ABC-123 = 3 The formula above searches fo ABC and gives you a value after = sign, no matter how long this value is. If there is no ABC it will return an error.
if there is no need to look for ABC then just use:
=RIGHT(F3;LEN(F3)-FIND("=";F3)-1)
I hope this helps. I cannot comment, so ask if you have questions.
Best - AB

Excel line up data

I'm a total Excel nub and can't find the answer I'm looking for. Must be easy peasy, but since I'm not into Excel I also don't know what to look for. Sorry if I'm having my question wrong.
I have output in Excel like this:
A 1
A 2
A 3
A 4
B 1
B 2
B 3
B 4
B 5
B 6
and I want it like this:
A 1 2 3 4
B 1 2 3 4 5 6
this question is quite complex in a way.
let me explain it more in detail:
as you see above, we have two columns A and B, you have text strings in column A , these text strings could be repeated. As you see in the example, there are 4 As, 5 Bs, 3 Cs 1 D and 3 Es. In column B each one of these strings have different corresponding values. For example, text strings B in column A has five corresponding values in column B, namely 11, 12, 13, 14, 15, and 16.
Now we want a list of UNIQUE values from column A, and lets say, we put this list in column C and then for each of these unique values in column C we want to list their corresponding cells in column B and put them HORIZONTALLY in front of each of these unique text strings in column C.
For this you need two kinds of formulas:
Formula 1 to calculate the list of the unique values in column A :
this goes in C2:(leave C1 empty)
=IFERROR(INDEX($A$1:$A$999;MATCH(0;FREQUENCY(IF(EXACT($A$1:$A$999;TRANSPOSE($C$1:C1));MATCH(ROW($A$1:$A$999);ROW($A$1:$A$999)); ""); MATCH(ROW($A$1:$A$999);ROW($A$1:$A$999))); 0)); "")
this is an array formula, so press ctrl+shift+enter to calculate the formula, and drag and fill down as many as you want in column C.
*Formula 2 to find and list horizontally the values from column B *
=IFERROR(INDEX($B$1:$B$999;SMALL(IF($C2=$A$1:$A$999;ROW($A$1:$A$999)-ROW($A$1)+1);COLUMN(A$1)));"")
this is an array formula, so press ctrl+shift+enter to calculate the formula, put this in D2 and drag and fill down until the last cell of column C. then select D2 to D6 and drag and fill horizontally. You should get all of the corresponding cells in front of each unique item.
P.S. adjust the formulas to meet your regional settings by replacing ; with , I suppose.
Finally here is the link to an example sheet downloadable from here .
This is very generic but hopefully will help.
Highlight the cells that you want to transpose to.
Type the equation..."=TRANSPOSE(B1:B4)" (edit as necessary).
While the cells are still highlighted, press "ctrl+shift+enter". (brackets should appear around the equation)
Finish editing the cells.
Celebrate

Resources