Insert rows into excel range via formulae - excel

I have the following range in column A :
01-Mar-12
01-Apr-12
01-May-12
01-Jun-12
01-Jul-12
01-Aug-12
01-Sep-12
01-Oct-12
01-Nov-12
01-Dec-12
01-Jan-13
01-Feb-13
01-Mar-13
01-Apr-13
01-May-13
01-Jun-13
01-Jul-13
01-Aug-13
01-Sep-13
In column B, I would like the same list of dates ( i.e. March 12 -> Sep 13), but I would like every August to be duplicated:
01-Mar-12
01-Apr-12
01-May-12
01-Jun-12
01-Jul-12
01-Aug-12
01-Aug-12
01-Sep-12
01-Oct-12
01-Nov-12
01-Dec-12
01-Jan-13
01-Feb-13
01-Mar-13
01-Apr-13
01-May-13
01-Jun-13
01-Jul-13
01-Aug-13
01-Aug-13
01-Sep-13
I can add as many columns in between as I like, but it must be done with formulae.
I'm having a little trouble figuring this out - any help would be much appreciated.

A formula is not capable of inserting rows.
Copy ColumnA to ColumnB, insert a cell and shift down immediately under each Aug and in the blanks created enter:
=R[-1]C

This formula works, assuming the values in column A are unique. Paste the formula into cell B3.
=IF(AND(MONTH(B2)=8,MONTH(B1)<>8),B2,INDEX(A:A,MATCH(B2,A:A,0)+1))
The current formula assumes that B1 and B2 are part of the list in column B. You'll have to manually fill in the values for B1 and B2 unless you change the formula a little.
What the formula does:
If B2 is August and B1 is not, then B3 copies the value of B2.
Otherwise B3 is the date in Column A found under the date B2.
You can then copy the formula into the remaining cells below B3.

Related

How to fix search to header cell?

I have a table like this:
Name
Response
Thursday
A
Monday, Thursday
Yes
B
Tuesday
No
C
Wednesday
No
This is an output of a Google Form response that I use to collect data, In Column C, every cell contains this formula:
=IF(ISNUMBER(SEARCH("Thursday",B2)),"Yes","")
To populate the "Yes". However, its quite cumbersome to replicate this if I want change "Thursday" to something else. When I try to insert it as C1, as I populate down the cells, it auto increment to C1,C2,C3 etc.
Is there a way to fix the formulate to
=IF(ISNUMBER(SEARCH(C1,B2)),"Yes","")
Across all cells and just have B2 increment?
Thanks!
The cell reference that you are using, such as C1, is relative to the formula position. So when you copy the formula one row down, C1 becomes C2 and so on.
To prevent this you need to make the row and or column address absolute so that C1 remains C1 when the formula is copied somewhere else. To make a row or column absolute, precede the row and or column by the character $. To keep the row absolute, you would use C$1 instead of C1. The key F4 will help cycle through the option when the cell address is selected in the formula.

How do we change column value and keep row constant in spreadsheet formula?

I have to calculate the value of cells A1 till A10 and it takes values from M21, N21, O21, and so on till V21.
How can I write a formula to calculate the same?.
I tried =M$21 to keep row 21 constant, but while dragging the formula down from A1 till A10, it doesn't change the column ref as it's dragging down.
How can I change the column reference to change while dragging the formula down from A1 till A10?.
I would index across the columns based on the current row:
=INDEX($M$21:$V$21,ROW())
use in google sheets:
=INDIRECT(ADDRESS(21, ROW(A13))
dragging this down will give you N21, O21, P21, etc.

Fill blank value in Excel

Need help in Excel for the following problem
ColA ColB
A1 B1
A2 B2
A3 B3
A4
A5 B5
A6 A6
A6
A6
if Column B is blank, I need to copy the value of ColA into ColB. But if the value is already present, then no action is needed.
Is it with formula or Vba?
A formula like should be ok (you copy/paste this formula to every cells in your Col)
=IF(B1="",A1,B1)
In column C enter the following formula:
=IF(B1="", A1, B1)
Copy this formula down column C. Then, assuming it looks right, you may delete the current column B, leaving the new column to become the new column B.
It is important to note that this formula won't work if directly entered into column B. In that case, Excel would complain about a circular reference.
Highlight the entire column B used range and press Ctrl+F to open find and replace then insert select
find " " (leave blank)
replace =OFFSET(INDIRECT(ADDRESS(ROW(), COLUMN())),,-1,1)
Which looks like:
Result:
This, INDIRECT(ADDRESS(ROW(), COLUMN()), refers to the cell itelf, and -1 column offset argument refers to column to left.
You can then do copy paste as values to convert formulas to hard coded values.

How to randomly select cell and the adjacent cell on excel

I am trying to find a formula on excel that will allow me to randomly select a cell between a range (this part I have found a formula for) and have the value pasted into another cell AND then have the cell next to the randomly selected cell's value also selected and pasted into a different cell.
Not sure if this makes sense so I will explain what I'm trying to do.
I have a column full of years and the adjacent column full of prices that correspond to each year. I want a year randomly selected and pasted into a cell lower down on the spreadsheet, and I want the corresponding price for this randomly selected year pasted next to this cell.
Thank you in advance!
Anna
Say the data is in A1 through B10
In D1 enter:
=INDEX(A1:A10,RANDBETWEEN(1,10))
and in E1 enter:
=VLOOKUP(D1,A1:B10,2,FALSE)
Another approach is to enter:
=RANDBETWEEN(1,10)
=INDIRECT("A" & C1)
=INDIRECT("B" & C1)
In C1 through E1
(Either approach will work if column A contains years rather than names)
Yet another approach is to enter:
=RANDBETWEEN(1,10)
=INDEX(A1:A10,C1)
=INDEX(B1:B10,C1)
In C1 through E1

Sum only matched values from two columns

Hello Everyone,
Does anyone know how to sum the Hours from column B (Hours) if column A numbers matched with column E and sum by months.
Example, take February data as an example, since only 3000 & 4000 existed in both column A & column E, that's why I need to sum the hours (20+10=30) from column B by it's month below.
I also attached the example excel sheet below.
https://www.dropbox.com/s/0s51g1i8g6s6e2d/Test.xls?m
Thanks in advance. :-)
You could get complicated with customer functions but if having an extra column (potentially hidden) doesn't matter then this would work:
In cell D2 enter:
=iferror(vlookup($A2,$E$2:$E$20,1,FALSE),"x")
Drag the formula down.
Under each month you can then put:
=sumifs($B$2:$B$16,$C$2:$C$16,B$22,$D$2:$D$16,"<>x")
Drag the formula across
This assumes you can change the month format in either column C or row 22 to be the same, ie. Jan, Feb, Mar or January, February, March etc.
Written on the fly and not tested so excuse any minor errors...
Both answers posted thus far are just fine, but just as an alternative, here's what I would do. Put this formula in cell D2 and drag it down:
=IF(NOT(ISNA(VLOOKUP(A2, $E$2:$E$20, 1, FALSE))), B2, "")
Then if you make a column containing the names of the months, say from G2 to G7 you have February, March, ..., July, you can put this formula into H2 and drag it down:
=SUMIFS($D$2:$D$16, $C$2:$C$16, G2)
That should get what you want.
Put this formula in Cell D2 and drag down:
=IF(NOT(ISERROR(MATCH(A2,$E$2:$E$20,FALSE))),B2,"")
In row 22, change the month names to be the full name, OR in column C, change the month names to abbreviated 3-letter names, this is so we can make use of the SumIf function.
Then, in Cell B23, put this formula and drag it across:
=SUMIF($C$2:$C$16,B22,$D$2:$D$16)
(I put the formula in row 24 to check against the data you already had in Row 23)
Shouldn't be much harder without a helper column. Just make sure you have full month name in row 22 to match column C data then use this formula in B23 copied across
=SUMPRODUCT(SUMIFS($B2:$B16,$C2:$C16,B22,$A2:$A16,$E2:$E20))

Resources