Excel formula changes when external source is updated - excel

Every row in the Q column computes the quantity of prime numbers(up to 9) in the 15 numbers in the same row. These 15 ones come from an external txt file.
Then, when I update the txt and refresh it in Excel, the formula on the last row changes so that it does not work the expected way.
It's hard to explain so here`s a picture:
Can anyone help me with this one?

Click on Properties under Data tab
Click on "Overwrite existing cells with new data, clear unused cells"

Related

Add text into cell formula in Excel to automatically select an other column with a drop down

This is quite an unsual question to fix my column problem from my Power Query mess.
I would like to add a text value to a selection name so it will dynamically select an other column name.
My goal is that my drop down would automatically do the following on every row from an other sheet:
=TableItems[#high]
=TableItems[#high.1]
=TableItems[#high.2]
What I want it to look like with dynamic drag formula
Anyone know if it is possible to add a value to a cell selection without having any errors?
I was able to offset my column by using a new column which I have called "Formula" and I just hide it.
This is the procedure I have done:
I took my TableItems selection and I have created a OFFSET formula of
=OFFSET(ItemInfo!D2,1,**4**,1,1)
The number 4 in my table moves 4 times to the right each times, so I have created a formula to multiply the number 4 by 2,3,4,5,6 etc.
The formula is the following:
=OFFSET(ItemInfo!D2,1,$H3,1,1)
=OFFSET(ItemInfo!D2,1,$H4,1,1) etc etc etc
IMAGE OF THE RESULT
I've had this problem for a couple of centuries, but I really hope this will help anyone else having a similar problem.

How to copy and paste formatting from the bottom cell of a table to the next cell below it?

I have a macro that cuts cells out of a table if the entries' date is > 2 weeks old. It then Deletes these cells. However, this causes my formatted area for data entry to shorten each time, so I am trying to find a way to fix this. My idea was to write a piece to copy the formatting from the last formatted row and paste it directly below it, but I am not sure how to go about doing this in VBA. I am newer to VBA and was wondering if anyone knew how to help? Thank you!
It sounds like your goal is to basically have your data entry table ALSO be your summary table, hence wiping out all entries greater than 2 weeks old. This seems like it will end up backfiring on you at some point - for example, what if you wanted to pull a report on everything you entered over the last year?
A better route would seem to be to have a single data entry sheet where you keep EVERYTHING and then a summary display that actively just pulls the data from the last two weeks. For that, you could use VBA to filter your data set based upon the date and then copy the information over to the new sheet (just do it once manually using the filter tool from the Home tab on the ribbon, while recording your actions to a new macro, and you should be able to clean it up pretty easily).
If you MUST edit in place, and presuming you don't mind it being sorted by date, record a macro where you select your full formatted range, turn on filtering, filter by your date column, delete the contents (just use the delete key) of the cells you want to wipe out, and then sort by date on the rest.
The cause of your problem is that in using the range.delete command you are removing the cell from existence (and hence shrinking your formatted range) - you just want to wipe out the contents and then move all your data up to fill the blank space.
good luck!

Generate summary gantt chart from detailed activities

I want to create a gantt chart summary that shows a person´s whole "busy" and "free" schedule by day and in a single row, from a detailed gantt chart with a list of activities of different people in multiple rows.
Basically go from this:
To this: (which I created Manually)
To be able to give a summary of people´s shifts free time between activities.
Right now I´m just using this formula to compare the start and end date in each row and produce a "1" if the condition is True, then I just condition formatted the whole Gantt cells.
=IF(AND(Q$8>=$N12,DAY($K12)<>DAY($J12)),1,IF(AND(Q$8>=$N12-0.00001,Q$8<$O12-0.00001),1,""))
I have no idea how to start. I was thinking of doing the nest things:
Create a table of the names of all the possible people to be added in the gantt chart.
Program the macro to create a new sheet with the same template.
Program a loop which starts iterating with each person´s name:
For each person´s name which exists in the gantt chart to be summarized, start creating new rows per each day they have activities scheduled (I can´t figure out yet how I´d iterate through this).
Within the each person´s loop, start iterating each row on the original sheet, evaluating each start and end date´s and pasting on the new sheet´s current person´s current day row a "1" if the condition was true in the corresponding hours.
Loop until all individual activities of each person are finished.
Continue with next person.
I´d like to know if this is the logical way to go and if you have any pointers or similar code to recycle, I am not proficient in VBA and Excel macros.
Not sure if I understand properly, but it looks like you got a set of multiple records where you store the times In and Out of each worker, several rows for each worker.
And based on that, you would like to resume data, one row per worker, highlighting start and end time of each worker, but all in a single row.
I made a fake dataset like this:
I added 2 extra columns (you can even hide them if you don't want to see them)
Field START TIME got this formula:=B2-INT(B2)
Field END TIME got this formula: =C2-INT(C2)
In Excel, Dates are integers values and times are decimal values. I used both formulas to get only the decimal part of each start and end.
All this data is a table object named T_WORKERTIMES. I made a table object so if you add new records, the Gant Chart will autoupdate.
Then I made a simple (kind of horrible) Gant Chart:
The formula I've used in H2 and drag is:
=COUNTIFS(T_WORKERTIMES[Worker];$G2;T_WORKERTIMES[start time];"<="&H$1;T_WORKERTIMES[end time];">="&H$1)
Actually, all my data is in same sheet:
I added 2 Conditional Formating Rules to highlight cells in green/white if the result of the formula is 1/0.
Also, working with times sometimes can be hard, because decimals. 0,677083333335759 means 16:15. But 0,6770833333333333 too, so in Gant Chart I rounded up headers to 6 decimals.
My formula in H1 is =ROUND(7/24;6)
My formula in J1 and drag to right is =ROUND(H1+1/24/4;6)
So now everything works fine. Please, notice in worker 1, there is no activites from 07:00 to 08:00. So I add a new row with that data and everything updates:
I've uploaded a sample yo Google Drive you can see the formulas and hope you can adapt this to your needs.
https://drive.google.com/file/d/1KOuCAYsmlY9gfNUCUhIrihXu-tJz-K7t/view?usp=sharing
Biggest issue here is the decimal part of times, to make sure they fit the Gant Chart. An easy solution would be substracting just 1 minute to start time column (calculated, you can hide it) and sum 1 minute to end time column (calculated, you can hide it).
Hope this can guide you in your project.
It looks like you are trying to extract unique records per person and day to get a person/day summary of time availability but also want it to be automated as you add more people and days.
I was able to do this with a combination of powerquery and a pivot table. When new persons/dates are added or changed the report will update but you will need to refresh using CTRL+ALT+F5
you want to highlight your entire report or an area as big as you think it will get. While highlighted you will then utilize named range feature under FORMULAS tab -> DEFINED NAMES ribbon -> DEFINED NAME dropdown. We could name it REPORTAREA or something like that.
Make sure you change the conditional format formula in report to show 0 instead of "" so this can work properly
2 go to DATA tab -> GET AND TRANSFORM ribbon -> From other sources -> Blank Query.
This will open the power query editor as a blank query
3 In the formula bar type =Excel.CurrentWorkbook() case sensitive is important
4 From there you will see CONTENT and NAME column.
In the NAME Column select the drop down and go to TEXT FILTERS -> Equals... Type in the name of your named range so the query does not pick up anything else on accident.
5 Remove the NAME column by right click selecting it and then remove.
6 you will notice the CONTENT column has two curved arrows pointing left and right instead of straight down like you are used to in excel. Click these arrows and make sure you uncheck the "use original column name as prefix" option box and ensure that the EXPAND option is selected. Then click okay.
7 At this point it looks alot like your report. Go to the HOME tab -> TRANSFORM ribbon -> Use first row as headers.
8.Select only the columns that are NOT THE 24 hr STYLE TIME LABELS of your report and then right click -> Unpivot other columns
9 At this point you can start removing some of the columns you dont want by right click and remove. Also double click and rename the columns as you wish. You can right click the top of the column and change types to what you want.
Dont worry about the 24HR style time zones not looking correct as this will be fixed later, this column should be changed to decimal type and not time zone type.
select a column that has the date information you need and right click -> Duplicate column -> change type to date.
11.At the top left part of the screen there is a CLOSE AND LOAD drop down where you will load to a new worksheet.
That will produce a green table. Select the table and press ALT+D+P to produce a pivot table linked to the green table you produced from the query.
You may need to close the Queries and Connections box that opened in order to see the pivot table options that will appear on you right.
Drag the 24hr style column to the columns area.
Drag the People to the Rows area and after Drag the Column you made in step 10 to the Rows area.
Drag the conditional format column to the Values area.
Your pivot table wont look exactly like what you want. while pivot table is selected go to DESIGN tab -> REPORT LAYOUT -> Tabular and also SUBTOTALS -> DO NOT SHOW SUBTOTALS while in the same tab.
13 Highlight all of the 24hr style time labels and format them and after highlight the inside of the pivot table where all the 1 and 0 will be and apply the conditional formatting you applied previously. Dont forget you changed the formula originally so your if statement does not end with "" but instead with 0.
If you would like i think it is easier to switch around the ROWS and COLUMNS area of the pivot table fields so that the report is easier to read. I have chosen to do so in the pictures. If you want to keep the report the way you are used to you can follow previous instructions.
I put the above comment down here as a complete answer.
I call those cells after "Finish date" column as "Chart cells". To extract a unique list of names, please refers to: here
If each name, you can use the followings formula and format for cells value >0 to show the bars.
=SUMIF([name range], "[each name]", [for each column of the chart cells])
If you further needs to filter by dates, you need to use sumifs() instead:
=SUMIFS([each column of chart cells], [name range], [unique name obtained from above], [Finish date range],"<=" & DATEVALUE("[target date]")+1,[start date range],"<=" & DATEVALUE("[target date]"))
This is the Excel formula solution, which is good if your table is not huge.

How do I prevent Excel from automatically replicating formulas in tables?

I'm using Excel 2016. I have a table with headers and when I plug in a formula, Excel is automatically replicating the formula to all other cells in the column. While that would normally be fine, it's wrongly calculating the table headers. I thought I could just change the top row to exclude the header but Excel updates the rest of the column which I don't want.
I would like to either turn this automatic formula replication feature off or figure out a way to customize the formula in the top row so it doesn't calculate the header value.
Here's the formula I'm using and I didn't do anything special with the table outside of add a 'Totals' row:
=SUM(B2+C1-D2)
You can stop creating calculated columns. The option to automatically fill formulas to create calculated columns in an Excel table is on by default. If you don’t want Excel to create calculated columns when you enter formulas in table columns, you can turn the option to fill formulas off. If you don’t want to turn the option off, but don’t always want to create calculated columns as you work in a table, you can stop calculated columns from being created automatically.
Turn calculated columns on or off
1) On the File tab, click Options.
2) Click Proofing.
3) Under AutoCorrect options, click AutoCorrect Options.
4) Click the AutoFormat As You Type tab.
5) Under Automatically as you work, select or clear the Fill formulas in tables to create calculated columns check box to turn this option on or off.
Stop creating calculated columns automatically
After entering the first formula in a table column, click the AutoCorrect Options button that is displayed, and then click Stop Automatically Creating Calculated Columns.
In Excel 2016/365 you can also change a cell you want, let it auto-populate the rest of the column, then Ctrl+Z, this will undo auto-populate but keep the new formula/text you just changed in that one cell.
First, why do you wrap a simple formula into a SUM function? I always wonder why people do that when it's much shorter to write =B2+C1-D2 instead.
Second, if you used the true capabilities of SUM() then text, i.e. your column header, would be ignored instead of throwing an error. The + and - operators don't tolerate text, be it in a table or not. You could rewrite your formula to be
=Sum(B2,C1,D2*-1)
Third, be aware that cell referencing like that will behave erratically when you insert rows into the existing table (between existing rows). The row references will be off for anything below the inserted row and you will need to manually copy down the formula again to get correct results.
In order to get a formula that does not require adjusting, you may want to use structured referencing, where each row has exactly the same formula, instead of cell references, where row references are adjusted in each row. A possible formula for this would be (if your columns are labelled data1, data2 and data3 for columns B, C and D):
=SUM([#data1],OFFSET([#data2],-1,0),[#data3]*-1)
To get the data from the row above, Offset() is used on the cell in the current row (using the # sign), with a negative row offset. Keep in mind that Offset is volatile, which may slow down very large datasets.
Adjusting AutoCorrect options is not optimal. You can do it on a col by col basis by:
let the column autopopulate your formula
delete any number of values in the autocalculated column (just one will do the trick).
adjust formulas in the column as you wish
Only able to test in Excel 2013.
May be a little late to open this query - but a couple of points:
formula replication does not work if there are already different formula in the column - may need 3 different formula before Excel says it cannot guess which formula to replicate
a solution could be to add 2 dummy rows at the top which will then prevent the replication - the benefit of this is that you are not disabling replication for any other tables that may be in the workbook; and I'm not sure if the setting may also inadvertently be copied to other new workbooks you create whilst you have the first workbook open
finally, the old chestnut that =A1+B2 etc creates an error if A1 or B2 are not numeric; whereas =sum(A1,B2) works differently in that text will be ignored and effectively treated as zero
If your reference has letters in the middle these technics won't work. To add a zero before the reference in that case, create a new column next to it, add "0" to all the cells next to the references, add another column and use the function "concontenate" or whatever between the "0" cell and the one with the reference.
Not only that, the =len function will correctly tell you the # of digits on references with letters in the middle (because excel does not view them as numbers per se, but rather text/general format) while on other references with 0s added before them with formatting this doesn't happen.
Eg: 012345 =len gives 5 digits / 01A345 =len gives 6 digits

Copying of data skipping blanks

Good Day, can somebody please help me. I have 2 spreadsheets, the second spreadsheet has got the copied cells exactly like the first one. But my problem is that on the first spreadsheet I have blank rows as the invoices are being put in date order and not invoices on every day. The second sheet I use for Vat purposes and want my selection there to be in list form in order to only print 1 page for bookkeeper. Where I have invoices for eg. on 10th, 15th and 20th on first spreadsheet "what formula can I use for the 3 invoices to appear in the second spreadsheet eg. in row 1,2,3 one right underneath the other one.
I have done VBA 20 years ago and came right with everything except this I can not figure out for the life of me. Thanks in advance to anybody that can help me with this.
highlight, press F5, click "special" select either "constants" or "formulas" depending on if it is hardcoded or formulaic data, then hit ok. this will leave all blank cells out of the selection, then copy paste as normal to the other workbook. if your doing it in vba this is all available in the object model as
Selection.SpecialCells(xlCellTypeConstants, 23).Select
Selection.SpecialCells(xlCellTypeFormulas, 23).Select
UPDATE: I forgot about the bug (design flaw?) in excel that makes it error out when you try to copy a non-rectangular selection. See here (the article is older but appears to apply to 2013):
http://support.microsoft.com/kb/100715
I believe there are macros available on the internet to deal with this problem, one of them is here
http://www.extendoffice.com/documents/excel/799-excel-copy-multiple-selections.html
A quick fix would be to take the inverse approach: use the "special" selection to select blanks, and then delete them. then select a rectangle around the remaining cells.
the VBA call to select blanks is
Selection.SpecialCells(xlCellTypeBlanks, 23).Select

Resources