Questions tagged [excel]

Only for questions on programming against Excel objects or files, or formula development. You may combine the Excel tag with VBA, VSTO, C#, VB.NET, PowerShell, OLE automation, and other programming related tags and questions if applicable. Do NOT use with other spreadsheet software like [google-sheets].

Microsoft Office Excel is a spreadsheet application written and distributed by Microsoft for Microsoft Windows and macOS. It features calculation, graphing tools, sorting and filtering data, pivot tables and a macro programming language called Visual Basic for Applications (VBA).

Languages and environments for programming against Excel include:

Questions tagged with should be version-agnostic. More specific tags include:

Version-specific tags include , , , , , , , , , ,

Microsoft Excel 2010 Microsoft Excel 2010 on Windows 7

More information

Useful resources

Official logo

Microsoft Excel official logo

Logo image source: https://products.office.com/en-au/products

281899 questions
201
votes
8 answers

How to keep one variable constant with other one changing with row in excel

Lets say I have one cell A1, which I want to keep constant in a calculation. For example, I want to calculate a value like this: =(B1+4)/(A1) How do I make it so that if I drag that cell to make a calculation across cells in many rows, only the B1…
dude
  • 2,013
  • 2
  • 13
  • 4
201
votes
14 answers

Find last used cell in Excel VBA

When I want to find the last used cell value, I use: Dim LastRow As Long LastRow = Range("E4:E48").End(xlDown).Row Debug.Print LastRow I'm getting the wrong output when I put a single element into a cell. But when I put more than one value into…
Mushahid Hussain
  • 4,052
  • 11
  • 43
  • 62
199
votes
20 answers

Is there a way to auto-adjust Excel column widths with pandas.ExcelWriter?

I am being asked to generate some Excel reports. I am currently using pandas quite heavily for my data, so naturally I would like to use the pandas.ExcelWriter method to generate these reports. However the fixed column widths are a problem. The…
badideas
  • 3,189
  • 3
  • 25
  • 26
199
votes
23 answers

How to read and write excel file

I want to read and write an Excel file from Java with 3 columns and N rows, printing one string in each cell. Can anyone give me simple code snippet for this? Do I need to use any external lib or does Java have built-in support for it? I want to do…
user177785
  • 2,249
  • 6
  • 22
  • 16
198
votes
7 answers

How to correctly display .csv files within Excel 2013?

It seems Excel 2013 doesn't read CSV files correctly (Excel 2010 does). Every time I open .csv files, all my data are displayed in the first column. I know I can go to DATA, Convert, and then choose commas, but this set up is not saved, and I am fed…
David
  • 4,785
  • 7
  • 39
  • 63
194
votes
12 answers

How to write to an Excel spreadsheet using Python?

I need to write some data from my program to an Excel spreadsheet. I've searched online and there seem to be many packages available (xlwt, XlsXcessive, openpyxl). Others suggest writing to a .csv file (never used CSV and don't really understand…
Jey
  • 2,199
  • 2
  • 14
  • 15
189
votes
16 answers

How can I perform a reverse string search in Excel without using VBA?

I have an Excel spreadsheet containing a list of strings. Each string is made up of several words, but the number of words in each string is different. Using built in Excel functions (no VBA), is there a way to isolate the last word in each…
e.James
  • 116,942
  • 41
  • 177
  • 214
186
votes
2 answers

How to save MySQL query output to excel or .txt file?

How do you save output of a MySQL query to a MS Excel sheet? Even if it's only possible to store the data in a .txt file, it will be okay.
Raja G
  • 5,973
  • 14
  • 49
  • 82
184
votes
20 answers

Import and Export Excel - What is the best library?

In one of our ASP.NET applications in C#, we take a certain data collection (SubSonic collection) and export it to Excel. We also want to import Excel files in a specific format. I'm looking for a library I can use for this purpose.…
Jason Kealey
  • 7,988
  • 11
  • 42
  • 55
182
votes
27 answers

Function to convert column number to letter?

Does anyone have an Excel VBA function which can return the column letter(s) from a number? For example, entering 100 should return CV.
intrigued_66
  • 16,082
  • 51
  • 118
  • 189
180
votes
5 answers

How to get the path of current worksheet in VBA?

I wrote a macro as an add-in, and I need to get the path of the current worksheet on which it is being executed. How do I do this? How do I get the file path (just the directory)?
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
180
votes
13 answers

Excel VBA App stops spontaneously with message "Code execution has been halted"

From what I can see on the web, this is a fairly common complaint, but answers seem to be rarer. The problem is this: We have a number of Excel VBA apps which work perfectly on a number of users' machines. However on one machine they stop on certain…
Phil Whittington
  • 2,144
  • 2
  • 16
  • 20
180
votes
22 answers

Best way to do Version Control for MS Excel

What version control systems have you used with MS Excel (2003/2007)? What would you recommend and Why? What limitations have you found with your top rated version control system? To put this in perspective, here are a couple of use cases: version…
TheObserver
  • 2,973
  • 7
  • 33
  • 41
175
votes
19 answers

Generating CSV file for Excel, how to have a newline inside a value

I need to generate a file for Excel, some of the values in this file contain multiple lines. there's also non-English text in there, so the file has to be Unicode. The file I'm generating now looks like this: (in UTF8, with non English text mixed in…
Nir
  • 29,306
  • 10
  • 67
  • 103
170
votes
5 answers

Pandas cannot open an Excel (.xlsx) file

Please see my code below: import pandas df = pandas.read_excel('cat.xlsx') After running that, it gives me the following error: Traceback (most recent call last): File "d:\OneDrive\桌面\practice.py", line 4, in df =…
LNQ
  • 2,587
  • 2
  • 5
  • 11