I have 1000 files in Excel format (Excel 2010) and each file contains 7 sheets with data.
This is an example for Excel sheet.
Is there a way to automatically convert the numbers that are stored as text to numbers, without affecting the actual text data? (maybe by VBA macros ? but I am a beginner in VBA code)
I can give you an algorithm, but I don't have time to write the entire code. I would write it in a seperate workbook, for repeatability. You can then either hardcode the 7 file names, or you can make an input for file name (the latter is a bit more flexible, if you need to use it for more files later).
Open a file
Loop all sheets
Loop all cells
If IsNumeric(Cell.Value) > Change format
You should be able to Google your way to the separate parts. Once you have some actual code, you can ask for more help on StackOverflow.
Related
This is perhaps one of those many times discussed questions with solutions more specific to actual system that outputs the data into a CSV file.
Is there a simple way to export data like 3332401187555, 9992401187000 into a CSV file in a way that later when opened in Excel, the columns won't show them in "scientific" format? Should this be important, the data is retrieved directly by an SQL SELECT statement from any DBMS.
This also means that I've tried solutions like surrounding the values with apostrophes '3332401187555' and the Excel cell recognizes those as text and doesn't do any conversions/masking. Was wondering if there was a more elegant way without actually it being a pre-set Excel template with text data fields.
1. Try exporting the numbers prefixed with single quote. Example: '3332401187555.
2. In excel, select the column containing number values
and then select Number in Format Cells.
Just have to save your file with Excel the option CSV file. And you have the in file in requested format.
Frequently in my job I need to generate reports with lots of tables of inputs and results. Especially for the result tables, one change in analysis may require editing a dozen spreadsheets. I'd like to create a macro in word that pulls in data from a spreadsheet, with each table on it's own tab, so that if I update any of those tables in excel the word document tables will also update. Given the number of tables/data points, I don't want to have to tell the macro to pull each single data point. The aim would be to reduce time and errors from manual entry.
I'm thinking this would involve the following steps, but not sure how to go about them:
1) Define the name/size for each table in word with matching name/size in excel
2) Tell the macro to pull the data into a table format
I'm not sure if this is possible as so far I've only seen how to insert a caption or a text box, not insert or update entire tables. Any help would be greatly appreciated!
Depending on what you're doing, you may not even need any VBA code.
If you copy a range from Excel and paste it into Word using Paste Special with the 'paste link' option, any subsequent changes in the Excel range will automatically be reflected in the document when the workbook is saved. And, if you name the range in Excel before copying/pasting, the Word content will expend/contract to reflect changes in the named range's scope in Excel. A variety of paste formats is supported.
Alternatively, you might use a DATABASE field in Word.
I have a C program that generates CSV files as output.
For example - I have 12 CSV files; one for each month. First column is Employee Name and Second column is their respective salaries. Assume there are 10 employees.
I want to format the 'salaries'column such that if a cell has a value over 10,000, the text should become green. Else it should remain blue. I have been able to do this using VBA for one file by adding a Command Button in the file and writing a small script.
However the issue is, every time I run my C code, it will generate a new set of CSVs; overwriting the existing ones. Besides, I want to apply such formatting to other CSV files I intend to generate.
I read that a .xla Add-In (which can exist on its own unlike embedded VBA macros in an Excel sheet) might be the solution.
I have 2 questions -
1. Is it possible to do with Add-Ins?
2. If yes, then I wanted to create a single batch file which would first generate the CSVs, and then run the Add-In on it. Is that possible too?
Thank You.
Lets say that I would like to read something from one Excel workbook, into another. This could be done typing
='C:\Documents\[MyOtherExcelFile]Sheet1'!A1
But suppose that I dont have a single file, but rather 100 (or 1.000) other Excel Workbooks, each from which I need a few values.
Assuming that they are named systematically like this:
C:\Doecuments\ExcelSeriesFile_0001.xlsx
C:\Doecuments\ExcelSeriesFile_0002.xlsx
C:\Doecuments\ExcelSeriesFile_0003.xlsx
(...)
C:\Doecuments\ExcelSeriesFile_1000.xlsx
Is there any way that I can automaticcaly create the name of the file, in the read command, getting the four digit number from a cell value in my original sheet?
Preferably I would like to do this without VBA, but if this is needed (or if it simply makes it easier/more effective) then VBA is okay.
Thanks in advance!
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!