Google spreadsheet relative row numbering + skip empty cell - excel

Using Google spreadsheet, I need a column to show relative row numbering, so that:
Spreadsheet rows can be moved around, and numbering stays relative (meaning that if I move row number 12 between rows 4 and 5, this row becomes number 5, previous 5 becomes 6, etc.)
Using a condition based upon a cell value in a given row, the row numbering cell may be empty (or not); if empty, that row number is being skipped, and numbering takes back up in the next row where the condition is unmatched.
Here is an example:
| Row nbr | B col. | [Explanation] |
|---------|:-------:|-------------------------------------|
| R01 | Value 1 | |
| R02 | Value 1 | |
| R03 | Value 2 | |
| | Value 3 | Col. B value = 3 => Col. A is empty |
| R04 | Value 2 | Numbering takes up |
| R05 | Value 1 | |
| | Value 3 | Col. B value = 3 => Col. A is empty |
| R06 | Value 2 | Numbering takes up |
| ETC. | | |
Here, the condition (to skip numbering) would be "IF corresponding B cell = Value 3" (then skip numbering)
Right now, I'm using a formula that matches requirement #1 above:
=ROW(INDIRECT("A"&ROW()&":A"))-9
(The trailing "-9" is just an offset so numbering can start at 01 from row 10).
So basically, I need to adapt (or change) this code so that besides relative numbering, for row N, if corresponding B column cell value = XYZ, then A column cell is empty (vs. numbered): that row is being skipped, and numbering takes back up from N on the next row where the B cell value ≠ XYZ.
Here's a Google spreadsheet example.
Many TIA's.

I strongly recommend not to use ROW() with explicitly specified offset in formula because should you delete/add rows above your table, your will have to adjust formulas in all cells. Here's my solution (column A:A is row numbers, B:B - values, start adding formula in cell A10):
=IF($B10="Value 3","",ROWS($B$10:$B10)-COUNTIF($B$10:$B10,"Value 3"))
Or if you insist on relative rows (change 10 to your offset from top):
=IF(INDIRECT("B"&ROW())="Value 3","",ROWS(INDIRECT("B"&10&":B"&ROW()))-COUNTIF(INDIRECT("B"&10&":B"&ROW()),"Value 3"))

Related

Index only cells in a column from another sheet if another cell in same row has a value greater than 0

So I have an example below of what I'm wanting to do.
Basically I need to Index Column B from Sheet 1 into Sheet 2 BUT ONLY if the values in Column W in Sheet 1 are greater than 0. If it's not then I don't want it to be included in. The only column to Index is B starting from row 5 to say 100. Same for Column W.
I was trying to do it myself as I found This which is very similar as what I'm wanting to do but I couldn't figure it out.
Sheet 1
Row# Column B | Column(s)… | Column W
=================================
5) Thing 1 | | 0
6) Thing 2 | | 3
7) Thing 3 | | 0
8) Thing 4 | | 1
Sheet 2
Row# Column B | Column C | Column D
=================================
5) Thing 2 | 3 |
6) Thing 4 | 1 |
7) | |
8) | |
EDIT #3
You can use either SMALL, LARGE function to return the values from Column B on your Sheet1.
Presume you have given the following names:
Sheet1ColB: Sheet1!B5:B100
Sheet1ColW: Sheet1!W5:W100
Here is the formula to be put in Cell B5 on your Sheet2. Please note it is an array formula so you need to press Ctrl+Shift+Enter to confirm.
{=IFERROR(INDEX(Sheet1ColB,SMALL(IF((Sheet1ColW>0)*(LEN(Sheet1ColW)>0),ROW(Sheet1ColW)),ROW()-4)-4),"")}
or
{=IFERROR(INDEX(Sheet1ColB,LARGE(IF((Sheet1ColW>0)*(LEN(Sheet1ColW)>0),ROW(Sheet1ColW)),ROW()-4)-4),"")}
You can then use INDEX+MATCH to return the value from Column W on your Sheet1 in Column C on your Sheet2:
=IFERROR(INDEX(Sheet1ColW,MATCH(B5,Sheet1ColB,0)),"")
In the above screen-shot Solution 2 is using AGGREGATE which follows the same logic as SMALL/LARGE.
As you can see the sample data has taken into account duplicated values in Sheet 1 Col W, blank cells in both Column W and Column B on Sheet1, and blank cells, negative value or 0 value in Column B only on Sheet1.
Cheers :)
Use AGGREGATE() formula to filter based on condition.
=IFERROR(INDEX($A$5:$A$8,AGGREGATE(15,6,(ROW($A$5:$A$8)-ROW($A$4))/($B$5:$B$8>0),ROW(1:1))),"")

Conditional Formatting Rule: Highlight Row when Cell Value in X Column Begins With

I'm trying to highlight rows in my spreadsheet where cell values in Column B start with qr.
I tried following ExcelJet's example "Highlight cells that begin with," but this method will ONLY highlight cells. It will also highlight other cells in other columns where cell's value (string) begins with qr.
I did come up with a small googled solution.
Created a rule within Conditional Formatting and used this.
=SEARCH("qr",CONCATENATE($A2, $B2, $C2, $D2,$E2,$F2,$G2))=1
The problem with this solution is it will concatenate the rows in which qr exists and highlight them. It will also do this to rows in which a cell's value other than in column B starts with qr.
May I get some help with this please?
I wasn't able to produce a solution table for my question, but the solution would be the same table with ROW 2 AND ROW 5 highlighted only. The current rule I'm applying will highlight ROW 2,3, and 5 and concatenate their cells.
|---|---------------------|------------------|---------------------|
| | A | B | C |
|---|---------------------|------------------|---------------------|
| 1 | Full Name | Username | Email Address |
|---|---------------------|------------------|---------------------|
| 2 | Mario | qrmrincon | mrodrigez#yahoo.com |
|---|---------------------|------------------|---------------------|
| 3 | Sofia | sgrahama3 | recio1#hotmail.com |
|---|---------------------|------------------|---------------------|
| 4 | Qrig | grecio1 | recio1#msn.com |
|---|---------------------|------------------|---------------------|
| 5 | Mora | qrmturner2 | turner2#aol.com |
|---|---------------------|------------------|---------------------|
For the Conditional Formatting formula, just use:
=LEFT($B2,2)="qr"
Then for the "Applies to" range, put:
=$A$2:$C$100
(Adjust that last row based on the data)
And just format as you wish (a Fill is likely what you want).

Aligning duplicates in Excel

I have 3 columns in Excel. The data in first column are complete dates from given year in ascending order. In second column are also dates but in between these dates there can be a missing day. So if i place these dates next to each other they do no line up. And in third column there is some date that corresponds to the date in 2nd column. Now what i would like to do is to align those dates, and where there is no date in first column the row is empty.
I have already put some code together for excel to lign up the data, but i dont know how to align the dates together with the values in third column(C column).
Here is my code:
=IF(ISNA(MATCH(A1;C:C;0));"";INDEX(C:C;MATCH(A1;C:C;0)))
Here is a visualization(the data in column A is all the dates in a given year. The data in column B and C must be moved together):
| A | B | C |
|1.1.2018 |3.1.2018 |12345 |
|2.1.2018 |14.1.2018 |54321 |
|3.1.2018 |2.2.2018 |56789 |
|4.1.2018 |2.1.2018 |11111 |
Desired output:
| A | B | C |
|1.1.2018 | | |
|2.1.2018 |2.1.2018 |11111 |
|3.1.2018 |3.1.2018 |12345 |
|4.1.2018 | | |
Based on your sample data this formula will search column B for the first instance of the date that is in column A and return the value from column C on that row.
In cell D1 and dragged down:
=IFERROR(INDEX($C:$C,MATCH($A1,$B:$B,0)),"")
MATCH($A1,$B:$B,0) will return the row number that the date appears in in column B.
INDEX($C:C$,....) will return the value from column C based on the row number returned by the MATCH function.
If nothing is found then an #N/A error occurs which is dealt with by the IFERROR(.....,"") function.

Find two matching rows and display data from the thirt one (Excel)

So i have Two Sheets.
First sheet contains two columns
BRAND | LEFTOVER
The second sheet consists of two columns also.
BRAND | LEFTOVER (%)
So in case if the BRAND row value in the first Sheet will match the BRAND row value in the second i want to display the matching LEFTOVER (%) row value in the first sheet rows in the column LEFTOVER.
Kind of lost here.
Appreciate any ideas. Thanks.
In Sheet2:
. A | B
--------------------
1 BRAND | LEFTOVER %
2 X | Y
3 |
In Sheet1:
. A | B
--------------------
1 BRAND | LEFTOVER
2 X | =VLOOKUP(A2,Sheet2!A:B,2)
3 |
The VLookup function searches for its first parameter (in this case the value of Sheet1!A2) in the first column of the range denoted by the second parameter (in this case the leftmost column of the range containing columns A and B on Sheet2)
It then returns the value from that same row of the range that is to the right in the columns denoted by the third parameter (1 is the leftmost column where the matched value was). So in this case we use the number 2 because 1 means column A and 2 is column B (which explains why we used a two column wide range for the second parameter - it needed to encompass the column the result was in)
This isn't the only way to do this, but it is the easiest.
As Jerry stated VLOOKUP is the simplest way to do this.
HOWEVER if you have multiple/repeat instances (rows) in BRAND, VLOOKUP will only return the first record (row) that appears in your data.
If this is the case, you will need to add either a unique identifier column; and/or additional criteria to differentiate between the repeat instances.
As an example column A is used as a unique identifier to differentiate between the 2 'Nike' rows.
A B C
1 BRAND LEFTOVER
2 Nike 50
3 Adidas 25
4 Reebok 30
5 Nike 29
I feel that you can use vlookup to accomplish your goals.
Let me explain it in a bit detail.Suppose you have two sheets as:
A | B | A | B
--------------------- | -------------------
1 BRAND | LEFTOVER % | 1 BRAND | LEFTOVER
2 X | Y | 2 X | =Vlookup(A2,Sheet2!A:B,False)
3 | | 3 |
Sheet2 | Sheet1
After this you can drag this formula for the entire range. This will automatically make the formula correct for the below cells as well.
Also, if you need to populate any other fields from the Sheet2 then you can also use the vlookup as an array formula like: VLOOKUP(A2,Sheet2!A:B,{1,2,3,4},FALSE)
Enter this as an array formula using Crtl+Shift+Enter
Here {1,2,3,4} stands for the columns to be fetched.
If you want to know more about vlookup then read this article: http://www.exceltrick.com/formulas_macros/vlookup-in-excel

Incrementing each row in excel that contains a number

I was sent an excel document in the following format:
A | B |
1 | abc |
| def |
2 | abc |
| def |
| ghi |
3 | abc |
| def |
So basically I have the first column which contains ordered numbers every couple of rows. I want to insert a row e.g. between 2 and 3, so that the new row will be numbered 3, and the rows below it are updated accordingly i.e. 3 becomes 4, 4 becomes 5 and so on.
I don't really use excel, but I am curious if there is there an easy way of doing this?
In A1, enter the following formula:
=IF(MOD(ROW(A1),2)=1,(ROW(A1)+1)/2,"")
And copy that formula down to the bottom of the range. Each time you insert a new row, you will need to manually copy the formula to the inserted row's first cell.
Is there a pattern in the b column, to distinguish if you need to jump to the next number?
if so use:
in cel A2 and further:
=IF(B2 = "abc",A1+1,A1)
With conditional formating, hide the repeating numbers: =A2=A1

Resources