How to autofill formula in excel, when a cell is deleted - excel

I have been trying to find a way to automatically add serial numbers when a data is entered in a row. Is there a way to auto fill formula across a column?
I have used this formula, =IF(B1<>"",A1+1,""), =IF(B2<>"",A2+1,""),... this works fine but the problem is when i delete contents in a row. the pattern breaks. I have tried COUNTA function as well, it works fine as well. But here also the problem is when I delete contents in a row, the formula gets deleted from the cell. Is there a way to retain formula and just delete the data without using "Go To" dialog OR Is there a way to auto fill formula in an entire column?

try this:
=SEQUENCE(COUNTA(A1:A))

Related

Trying to add formula directly to a cell in VBA and it disappears?

I have an input form where someone puts in numbers and clicks submit so it records on a table. I realized I want to have one cell on the input sheet calculate a percent automatically instead of having to calculate it manually. The problem is that every time I enter the formula and then use the clear macro, the formula disappears instead of just the value within. I have other cells with formulas that this does not happen to so I am assuming there is some way to fix it and make it like the others. In the code it is using
Range("ccmcocc").ClearContents
just like the others with formulas.

How to auto fill a specific complex formula after inserting new row to a defined Excel table

I've been looking for a way to automatically insert a row, where a column contains an Index(Match) formula.
I've looked at several tutorials and forum where it says formulas should auto populate because it's part of the Excel table function, especially if auto-fill feature is enabled. However, my formula is the following, and will not process.
=INDEX('Lookup Tables'!$M$20:$M$26,(MATCH(**H2**,'Lookup Tables'!$N$20:$N$26,0)))
This formula is in Cell G2. Adding info into cells G3, G4 would make the following formula on the column to the right.
=INDEX('Lookup Tables'!$M$20:$M$26,(MATCH(**H3**,'Lookup Tables'!$N$20:$N$26,0))),
=INDEX('Lookup Tables'!$M$20:$M$26,(MATCH(**H4**,'Lookup Tables'!$N$20:$N$26,0)))
Basically, when a new value is entered on H3, H4, H5, etc, the =index(match) formula should automatically populate, but this doesn't work.
I thought of just adding an =iferror(Formula," ") but that just expands the table indefinitely and adds too many blank columns (my table has over 20 columns).
Only way I could think was to write a VBA script, but I'm stuck on what to do or where to even start.

Skipping blank cells with an Index/Match formula

I've got several databases containing 100/1,000's of rows where the information is presented something like this:
I need to get all the information relevant to each company onto one row; I'm not able to do a simple Sort & Filter as nearly every company has a different level of detail, so information ends up in the wrong rows. Looks like the best option is an Index/Match formula, but my current formula
=INDEX(Sheet1!B:B,MATCH(Sheet2!$A2,Sheet1!$A:$A,0)
returns zeros for any result where the first Index/Match result is blank:
How can I write the formula so that it skips the blank cells? I'd prefer not to have to use VBA however any advice would be very much appreciated.
Alternatively,
Because match is always the return the first value it found.
So in cell G2,
=INDEX(Sheet1!G:G,MATCH(Sheet2!$A2,Sheet1!$A:$A,0)+COUNTA($G$1:G$1)-1)
Or by matching the header to offset the cells.
You can just wrap your existing formula in an IF function:
=IF(Sheet2!$A2<>"",INDEX(Sheet1!B:B,MATCH(Sheet2!$A2,Sheet1!$A:$A,0),"")
I will normally use a "Go To Special" function for this.
Say for example for the sample data below.
I will put in the first formula '=IF(B2<>"",C3,"")'. Copy that cell (Ctrl+C), then select cells from C2 to C7 and use the 'Go to special' to select Blank cells only under Home tab, in Editing > Find & Select > Go To Special. Simply just Paste the formula to all the blank cells by Ctrl+V. You will get all the information in one row on the first row for each companies.
Hope this helps.
Step1:
Create a pivot table with your data and in the pivot options select 0 for the blank cells.Copy all the fields into row area...
Step2:
Apply conditional formatting as shown in the below image to remove (blank) cells.
Note: This is not a robust solution but worked for me.

How to add formula to multiple cells with already existing values in them?

I have a table filled with hundreds of values in different cells (not coming in order, chaotic). Now I want to add 20% to each value (=x*1.2).
what formula should I use?
A quick way to get the desired result is to add a new table or worksheet and copy the update formula in each cell (e.g =A1*1.2). You could then overwrite the old values by pasting the new values. Pasting values overwrites any old formula.
If you want to manipulate the formula of every cell, you should look into a vba solution.
This is my solution:
1. Write a 1.2 in an empty cell out of table.
2. Copy this cell (1.2).
3. Select the table with values. Right-click of the mouse, select Paste Special -> Paste Special..-> Multiply. Voila!
Result: all selected values in the table were multiplied by 20%
Thanks a lot to my colleague Lina!

Vlookup formula in excel

I was hoping someone could offer me a little help please on a formula. In one of my cells I use a vlookup to search for the colour in B12 and match it to the colour on another worksheet called cars.
Now this works perfectly fine, but after running the formula I have to select the last row of data and press control & d, or drag down the cell up until the last cell, my question is that is it possible to add this forumla into the cell and have it automatically run all the way down to the last row of data? my forumula is
=VLOOKUP(B12,coloursc:carsc,2)
You can use an Excel table for your data entry. Formulas and formatting will automatically be applied to any new row in the table. You no longer need to manually copy down or pre-fill empty areas of the spreadsheet with formulas.
Learn more about tables in this Microsoft article and this tutorial on Contextures.com

Resources