We have a lot of automated spreadsheets that extract data, calculate forecasts, publish web pages, etc. It's a really messy system, and I'd love to redo it (with, say, a real web service), but we don't have permission to do that.
We run Excel 2007, with most of the spreadsheets converted to .xlsms.
Anyway, for some reason unknown to me, certain spreadsheets will format certain numeric cells as dates at seemingly random times. As you might imagine, the problem is difficult to track down, and usually I only find out when someone has written a nasty email about our data reading 3-Feb-1901 when it should read 400 (apparently Excel thinks there was a leap year in 1900).
I've explicitly set the cells in question to numeric format several times, only to find them filled with dates a week later.
I've scanned the macros (many are in the ancient Excel 4.0 macro language), they appear to be clean of any formatting changes. All copy/pastes are done as values and do not preserve source cell formatting.
There are no conditional formatting rules in the sheets in question.
Adding a little VBA to format the cells as desired in the Auto_Open subroutine appears to work around the issue.
Is this fix good enough, or in a week will I find the date format is appearing mid-calculation? If not, what is the root cause and how I can fix it?
One thing: I just read from this source that Excel '07 may spontaneously change Normal-styled cells to the format [$-409]m/d/yy h:mm AM/PM;#. Some of my cells that have changed were definitely styled Normal, but evidently not all.
I'm assuming the cells in question are the receipients of copied/pasted data, or external/queried data?
Whenever you add pasted data to a cell in excel, it runs througha routine to determine the best format for anything that's listed as "general" format, even if the source is "general" or "number". Sometimes even setting the destination cells to "number" format does not clear up this issue. But I've found the only way to to get this to work the way you need it to is to explicitly declare the format (in the macro) to the destination range in question before the paste/update/refresh operation.
I also think there's a way to disable date recognition within your VBA, but I can't remember the exact code. Try recording a macro while doing manually importing or performing your update and you should be able to use what comes up.
Edit: just did a test run, and after your connection string and destination add:
.WebDisableDateRecognition = True
That should definitely do the trick if you're pulling data in from an external source and not copy/pasting.
Just in case this helps, i had an issue where excel was auto formating my info pulled from a webpage into DATE format, to fix, in the import window, click options and UNCHECK the auto date formating option, after that, my data imported perfect!
Related
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.
this one's a bit of a painful one so thank you for your help and patience with me.
We have an Excel spreadsheet that we use as a master file for our website products. As such there are quite a few sheets and quite a few products on each running along side some macros to provide some extra functionality (turning entered data into HTML for product page, etc).
My issue is that one of our most used spreadsheets has become a trouble in that it has some phantom formatting all the way down to the millionth-and-something row and all the way across, causing the last cell to be the very last cell possible.
The issue that has finally popped up as a result is that we can no longer move rows in, out or around the sheet (a required functionality) as it results in an 'out of resources error'.
I've tried:
Highlight all rows below used range to right-click> delete - Results in runtime error (from macro)
Highlighting large chunks of rows and using Clear All - Resulted in the 38MB file bloating to 380MB
Deleting a chunk of rows at a time - Maxed out at 1,000 before it caused Excel to crash
Moving to new spreadsheet - Broke all our macros (which I did not write and am not proficient enough to fix on a new sheet)
Disabling macros and trying the above options, only marginally more efficient but still out of resources
I'm at my wits end on this one and, while we can continue with most day-to-day functions, we will soon be completely unable to use this particular sheet as we need it at all.
I'm wondering if there might be a way to run a VBA script to remove these rows, potentially one by one? I've tried running a short script that went something like rows[960,1000000].Delete (forgive my terrible VBA markup), but this also resulted in not enough resources errors.
I'm wondering if there's anything like:
row = 960;
while(row<=1048576){row.Delete};
Continuing, the runtime error debug points me to the below if statement within the macro:
If Target.Count > 1 Then Exit Sub
Where Target is the variable passed to the sub.
Which strikes me as very odd because my (limited) understanding of VBA and IF's in general simply recognizes that 'if my selection is larger than 1 (row?), do not run this code..
Thanks again in advance.
Use this method only if you don't have any links into or out of the sheet that will get broken. Also might have Sql connections that might get broken. Might need to disable macros. There are many possible problems with this approach. Use at your own risk.
Note the exact "Name" and "(Name)" of the sheet; Look in the VBA code window at the properties for the sheet. "Name" is the name displayed on the worksheet tab. "(Name)" is the code name visible only in the properties window.
Make a list of range names on the sheet.
Copy the data to a new sheet.
Copy any macros to the new sheet.
Delete the old sheet.
Rename the "Name" and "(Name)" of the new sheet the same as the old one.
Recreate range names.
A better method if you don't have too many formats:
Disable macros and set calculation to manual. This avoids recalculating while doing your delete operation.
Select entire sheet and clear formats.
Delete all rows below your data.
Redo your formatting. Select entire column (not just used area) to apply format if applicable.
It is important to remove formatting on the entire sheet from A1 to the end. Otherwise you'll get the bloat you mentioned. Just that step may solve your problem. If not then proceed with removing all the rows below the data. This should not cause file size bloat.
Google has not found the solution i need so i thought i would try the genius on here to the never ending Excel issue I'm having.
Running a banking reconciliation workbook and slowly adding bits of VBA together to automate some of the tasks, one I'm working on now is finding large quantities of money and renaming their Identifier from a bank statement to same ID in our cashbook to they are found and will balance out.
To do this I'm running a IF(Vlookup()) returning a yes or no on the cash value and then reordering them once they are found so i can line them up and match them correctly.
The main issue I've got here is the vlookup is ignoring some values which i can see and saying no not found and i messed around figuring out why and until i clicked to edit the cell and then pressed enter not changing the amount and all of a sudden found and it only finds it in the vlookup if i click the cell and press enter.
I have tried Formatting, changing calculation to automate and tweaked the vlookup to include a +0 as well as changing the exact match to approximate and it still won't find it, i even tried trimming and checked the Len for whitespace and both equal the same.
Currently trying a for loop to select a cell and change it to itself so it mimics the select and enter but it runs slow and crashes.
Anyone got a decent idea of fixing this miss when searching
This often happens to me when pasting data from somewhere. It may have been pasted as text but then when you edit and press enter it changes to numeric.
The solution is to use =VALUE() to change the numbers to numeric.
Or when you paste the data from another source choose paste special as text.
VLOOKUP works strangely when is asked to do an approximate match with the look-up table unsorted by the look-up column.
If you're sure that an exact match should be enforced in your look-up column, try something along the lines of:
VLOOKUP(<lookup_value>, <table_array>, <col_index_num>, FALSE)
where <lookup_value>, <table_array>, <col_index_num> should be replaced with the values that you use in your look-up.
I have a VBA code that helps users schedule projects by entering either a date or days until completion for particular tasks and then creates a graph that shows the percent completion of the project.
The VBA code hinges on the formatting of the cell to perform its calculations. Excel does a great job of choosing a number or date correctly the first time a user inputs a value. However if a user was to input a date and then decide to input a number (ex: 7) they would end up with 1/7/1900 as the date, which then makes excel perform the VBA incorrectly.
Is there a way to get Excel to "reconsider" the formatting of the cell each time it is changed? If not is there a way to force it to do so in VBA and choose either number or date formatting only?
Thanks,
-MK
Yes,
as a user prefixing an "=" is probably your best bet.
Adding "e0" on the end will format as an ugly scientific number, but at least it's accurately represented in memory.
Another option is multiplying by 100 followed by a "%".
You've accurately noticed that dates to numbers don't change back as easily. On the other hand any entry with a front-slash '/' seems to format as a date pretty reliably. The single apostrophe ' formats as Text, which is not very good for automated solutions. A number by itself is too general to change the NumberFormat, so any "automatic" solution would be non-standard.
We have are relatively simple Reporting Services report that our users commonly export to Excel. I've noticed that the files produced by the Excel export seem unusually large. If I open one of these files and just click save, without making any changes, the file size reduces to about half of it's previous size. Has anyone else run into this and is there a known workaround?
You've mentioned that the report is relatively simple, but this is important to check. The export to Excel will go to extraordinary lengths to try and maintain how your report looks.
If you have lots of different borders or colours (particularly if different formatting is determined by the data in your report) this will bloat the file.
Also check if many columns with very small and unusual sizes are created in the exported worksheet. The export does this to try and match alignment in Excel with the original report.
Try recreating your report as a basic table with no formatting or headers/footers and see if you can reproduce the problem. If Excel's behaviour is acceptable then add each piece of formatting back until it goes awry. Please let us know what you find.
I don't have an immediate solution, but a common problem in Excel is files bloating because one/some/all of the worksheets have saved all 64K rows instead of the ones being used. The fix in Excel is to select all the lower rows not being used, and delete them, then save the spreadsheet, close and reopen. Therefore, I'd pursue the angle of extra rows being saved in the export, and see if there is a way to keep this from happening.
What tool are you using when exporting to Excel?
I have also managed to reduce # of rows in my Excel worksheet by copying it to another worksheet, then deleting the original sheet.
You could also try copying only the data in your worksheet, and paste it into a new Excel Workbook (file).
I had the issue where the exported Excel files took and extremely long to open and they would stop responding every time you clicked on a cell.
Also, extra and merged columns would appear in exported excel files.
The fix was to make sure my header text boxes lined up with the beginning and end of columns in the data table just below it. Once both were aligned, there were no more extra columns in the exported excel spreadsheets and the performance was back to normal.
Here's the reference that helped me understand the issue:
http://www.codegur.press/12747988/issue-report-export-to-excel-in-rdlc-report
May be I am answering your question very late. Here's the solution for exporting to CSV.
You need to give the a name that you want to see as a column header for the field (not the column name) in the designer.
By default all the text headers are exported as a separate columns along with the table columns and make sure that you name the Design name in the properties with the name you want to see.
The other important thing to note about the option DataElementOutput which is set to Auto meaning it will be exported. You can change that if you don't want it to be exported.
The last but not least thing ... after you export the data looks messed up. You need select the whole first column and go to the Data tab - > convert text to column -> use the delimiter as comma and say Finish. That should solve your issue.