Excel formulas have stopped working - vba

I have excel sheet which has basic + Array excel formulas, earlier it used to work properly but for the last 1 week it is not give me desired result.
I have tried the following things but nothing seems to work.
Change the formula setting from manual to automatic.
Change the format of the cell from text to General.
No space before the equal sign.
Note: I am using 2010 excel and rest in my office uses 2013 and we shared everything on common folder. Is this can be one of the reason ?

Regarding the ANZ formula, the rows have to match. Someone inserted 12 rows into part of Trades worksheet and this expanded the range to U1:U65548 and Z1:Z65548. The AW column remains at AW1:AW65536. While the ranges can be offset from each other, they have to be the same size.
This shows up on your formula for the FINEX as well.

Related

Changing a file location for 10,000+ cells in Excel

I'm creating a workbook in Excel, and need it to reference other workbooks. I am pulling information from about 30 cells for each day of the year. Each day of the year is a separate workbook. So, I have over 10,000 cells that I need to change if I just copy and paste the formulas for each day.
The reference I have right now is something like this:
='C:\user\data\year\[day.xlsx]Sheet1'!A1)
Where that A1 will be replaced by 30 other cells, and the day.xlsx will be replaced with all of the days in a year. For everything I've tried so far Excel has asked me to manually locate each file per cell.
Is there any way to make this process quicker than manually changing the file name for every single one of these cells? Maybe be able to set the date in the file name to a variable that will link to a cell?
Any guidance would be appreciated. Thank you.
To summarize: You want to create addresses in the stated format by string manipulation and then query their value.
There is in fact a function for this, it is called INDIRECT. Unfortunately it requires the source file to be open for external references, so I'm not sure if it is any help to you. I have never tried to open 365 excel files at once.
See also this question on that topic.
If you do not wish to open all the files by hand you will probably have to fall back on VBA (or perhaps JavaScript if you use Office 2016). It shouldn't be to difficult to create a macro which generates the references for you.
Here is a starting point for such a macro:
Sub Makro1()
Dim day As Integer
For day = 1 To 365
Cells(day, 1).FormulaR1C1 = "='[BASENAME" & day & ".xlsx]SHEETNAME'!R1C1"
Next i
End Sub
One more thing: After that your workbook will be linked to all those day-files. As such it will reflect changes as they occur in the day-files. If that is not required it would probably be best to sever the connections and replace each reference with its value. You can do that via Data->Queries&Connections->Manage Links->sever connection (I'm translating from my localized excel version so the exact names may vary) OR you can just copy every thing and then paste only values.

Plot a pie chart when the number of columns within the range varies

Month Organic Direct
Dec-15 £3,112 £0
I recorded VBA code that plots a pie chart for the above data. The data I am exporting can have up to 6 headings (the above example shows two headings). The code is set up to select a range that is 6 columns wide. Charts need to be adjusted manually when less than 6 headings have been exported.
What do I need so the range used fits only the data e.g. when there are only 2 headings rather than 6?
I don't know how much help you need, since you posted no code.
In the simplest case, in Excel 2013 and 2016 you can use
ActiveSheet.Shapes.AddChart2(251, xlPie).Chart.SetSourceData _
Source:=ActiveSheet.Range("A1").CurrentRegion, PlotBy:=xlRows
In Excel 2007 and 2010 (and 2013 and 2016, but it doesn't have the nicer default style applied):
ActiveSheet.Shapes.AddChart(xlPie).Chart.SetSourceData _
Source:=ActiveSheet.Range("A1").CurrentRegion, PlotBy:=xlRows
This assumes the data starts in cell A1 and the data being plotted does not touch any other data (that is, there is a blank column to the right of the last column of data, and a blank row below the two rows you've shown with labels and data). CurrentRegion finds the data-containing region surrounding the reference range (the reference range in this case is cell A1), up to blank rows and columns.
Does this all take place in the same workbook?
i would start by looking at dynmamic ranges,
Heres a good starting point:
https://www.thespreadsheetguru.com/blog/5-ways-to-create-a-dynamic-auto-adjusting-vba-range
and also look here:
Using VBA to select a dynamic range of cells and create a chart

Excel formula or VBA script to group data

Here is a screenshot of a sample data set that I am trying to work with in Excel
I want to use either an Excel formula or a VBA script to populate the firm_anamoly column (it's manually populated right now).
The logic is that for set of rows in a given firm number, if there are more than one "sector23code"s in that set, the output in column "firm_anamoly" should be "firm_count", else "firm_anamoly" should be set to 0.
As you can see for firm_number = 5, since sector23codes are both 3 and 5, firm_anamoly is set to 3, i.e. firm_count.
I have around 500K rows of data that I am trying to work with.
Thank you.
There are 2 ways you can go about this. One way is to do it without converting your range to a table format.
Method 1:
You can enter this formula in cell D2:
{=IF(AND(IFNA(IF(A2=$A:$A,$B:$B,NA())=B2,TRUE)),0,C2)}
This will get you the results that you want I believe but it will probably overwhelm your Excel if you have a less than powerful system.
I would most recommend
Method 2:
Convert your range to an Excel table. Then enter this formula in the first row of the 'firm_anomoly' column:
{=IF(AND(IFNA(IF([#[firm_number]]=[firm_number],[sector23code],NA())=[#sector23code],TRUE)),0,[#[firm_count]])}
This version will run much more efficiently than Method 1.
Both of these are examples of Array Formulas so when you enter them hit ctrl + shift + enter to get the curly brackets to show up. Since you have so much data you should definitely back up before entering this formula; array formulas on large data sets can sometimes crash Excel.

Excel: How to compare sheets from 2 different workbooks for differences

I have an original excel file that I have ran a simulation that inputs financial data. I made a copy of this file, and wired the formulas up differently to try and increase calculation performances.
I now have 2 workbooks, the original and the final. I want to compare each sheet from each of the workbooks together to make sure that the financial numbers have remained the same, to make sure the new formulas are not effecting the numbers received.
I have tried to put copies of the two sheets into one workbook, name them April12 and April15. Then insert a third sheet. In cell A1 of the third sheet, I wanted to use the formula
=April12!A1=April15!A1
to get TRUE/FALSE values. But the formulas in these sheets reference many other sheets that are not in this new workbook, so all of my numbers turn up as #REF.
Iv googled many different ways of approaching this but I cant seem to get any of them to work. Does anyone know a simple way I can compare just the values from 2 sheets from 2 different workbooks to find out if the numbers have remained the same or have changed?
Note:I am using excel 2010.
I think you already know how to verify data using formula so is the problem to refer to a row in a different workbook ? if so, following might be helpful :
=[yourFile.xls]SheetName!$Col$Row
this way you can update your formula like(yourFile.xls refers to the complete path including the file name) :
=[file1.xls]April12!A1=[file2.xls]April15!A1

AutoFit not adjusting row height in VBA code in Excel 2007

I know many discussions have addressed this but I have not found a solution.
I regularly produce worksheets with about 100 records of text and date fields, each of which must be transposed into a 2-column table and printed to a PDF file.
To do this I have been using VBA code which works through the worksheet rows to sequentially: copy/transpose into two columns in a separate worksheet (Template) and then use rng.ExportAsFixedFormat Type:=xlTypePDF to create the PDF file.
It has all been working fine for several years, until someone recently noticed that sometimes the largest field does not show all the text from the Excel cell. It is invariably cut off after about 1000 - 1100 characters.
Many discussions mention that there is a 1024 limit on cell displays, but I thought this only applied to Excel 2003 and before - 2007 should be fine shouldn't it? In any case, I have found it is always possible to manually adjust the Excel field to reveal all of the text (both in the original worksheet and the temporary 2-column Excel table), sometimes totalling more than 2000 characters. Of course, I don't want to manually adjust and print to PDF 100 times on a regular basis. So I used AutoFit: Sheets("Template").Rows("1:18").Selection.EntireRow.AutoFit
Unfortunately this does not seem to duplicate the manual cell expanding that we have tried successfully. None of the cells is merged. All are wrapped and General formatted. I have tried cleaning text entries via Notepad before entry and inserting blank rows with Alt-F (as suggested elsewhere).
If AutoFit will not work, I am thinking maybe I could include some code to set a customised row height for each table by getting the total word count (is there a function?) and setting row height to about 0.8 * number of words - based on initial calculations.
Any ideas please?
I've used a method similar to what you suggested your last paragraph but with a character count instead of a word count. The VBA function is:
len(range("A1").value)
I did it since I had merged cells and they wouldn't autofit.
You'll have to calibrate for your column width, font and font size but from what I've learned there's no exact method. If you set your characters per line factor too high you might cut off a line, too low and you might get a blank line.