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
166
votes
6 answers

How can I send an HTTP POST request to a server from Excel using VBA?

What VBA code is required to perform an HTTP POST from an Excel spreadsheet?
Matthew Murdoch
  • 30,874
  • 30
  • 96
  • 127
165
votes
16 answers

How to write to an existing excel file without overwriting data (using pandas)?

I use pandas to write to excel file in the following fashion: import pandas writer = pandas.ExcelWriter('Masterfile.xlsx') data_filtered.to_excel(writer, "Main", cols=['Diff1', 'Diff2']) writer.save() Masterfile.xlsx already consists of number…
BP_
  • 2,497
  • 5
  • 18
  • 18
165
votes
24 answers

How can I read numeric strings in Excel cells as string (not numbers)?

I have excel file with such contents: A1: SomeString A2: 2 All fields are set to String format. When I read the file in java using POI, it tells that A2 is in numeric cell format. The problem is that the value in A2 can be 2 or 2.0 (and I want…
joycollector
  • 1,986
  • 4
  • 17
  • 18
158
votes
5 answers

How do I put double quotes in a string in vba?

I want to insert an if statement in a cell through vba which includes double quotes. Here is my code: Worksheets("Sheet1").Range("A1").Value = "=IF(Sheet1!B1=0,"",Sheet1!B1)" Due to double quotes I am having issues with inserting the string. How do…
user793468
  • 4,898
  • 23
  • 81
  • 126
156
votes
9 answers

How do I declare a global variable in VBA?

I wrote the following code: Function find_results_idle() Public iRaw As Integer Public iColumn As Integer iRaw = 1 iColumn = 1 And I get the error message: "invalid attribute in Sub or Function" Do you know what I did wrong? I…
Nimrod
  • 2,343
  • 3
  • 17
  • 7
153
votes
24 answers

Test or check if sheet exists

Dim wkbkdestination As Workbook Dim destsheet As Worksheet For Each ThisWorkSheet In wkbkorigin.Worksheets 'this throws subscript out of range if there is not a sheet in the destination 'workbook that has the same name as the current…
yse
  • 1,541
  • 2
  • 10
  • 4
153
votes
25 answers

Importing CSV with line breaks in Excel 2007

I'm working on a feature to export search results to a CSV file to be opened in Excel. One of the fields is a free-text field, which may contain line breaks, commas, quotations, etc. In order to counteract this, I have wrapped the field in double…
jeremyalan
  • 4,658
  • 2
  • 29
  • 38
149
votes
15 answers

Which encoding opens CSV files correctly with Excel on both Mac and Windows?

We have a web app that exports CSV files containing foreign characters with UTF-8, no BOM. Both Windows and Mac users get garbage characters in Excel. I tried converting to UTF-8 with BOM; Excel/Win is fine with it, Excel/Mac shows gibberish. I'm…
Timm
  • 2,488
  • 2
  • 22
  • 25
149
votes
13 answers

Generate sql insert script from excel worksheet

I have a large excel worksheet that I want to add to my database. Can I generate an SQL insert script from this excel worksheet?
user2323240
  • 1,607
  • 2
  • 13
  • 15
148
votes
16 answers

IF statement: how to leave cell blank if condition is false ("" does not work)

I would like to write an IF statement, where the cell is left blank if the condition is FALSE. Note that, if the following formula is entered in C1 (for which the condition is false) for example: =IF(A1=1,B1,"") and if C1 is tested for being blank…
Mayou
  • 8,498
  • 16
  • 59
  • 98
144
votes
20 answers

Python: Pandas pd.read_excel giving ImportError: Install xlrd >= 0.9.0 for Excel support

I am trying to read a .xlsx with pandas, but get the follwing error: data = pd.read_excel(low_memory=False, io="DataAnalysis1/temp1.xlsx").fillna(value=0) Traceback (most recent call last): File…
Vineeth Sai
  • 1,497
  • 2
  • 9
  • 10
143
votes
12 answers

Best timestamp format for CSV/Excel?

I'm writing a CSV file. I need to write timestamps that are accurate at least to the second, and preferably to the millisecond. What's the best format for timestamps in a CSV file such that they can be parsed accurately and unambiguously by Excel…
Jon
139
votes
6 answers

Insert picture into Excel cell

I'm tying to generate a report with pictures, but I cannot get the pictures into a single cell. I can get the pictures to "float" around my worksheet, but I need to put them into a cell. How can I do this?
Reid
  • 4,376
  • 11
  • 43
  • 75
139
votes
16 answers

Simple Pivot Table to Count Unique Values

This seems like a simple Pivot Table to learn with. I would like to do a count of unique values for a particular value I'm grouping on. For instance, I have this: ABC 123 ABC 123 ABC 123 DEF 456 DEF 567 DEF 456 DEF 456 What I want is…
user1586422
  • 1,393
  • 2
  • 9
  • 4
137
votes
12 answers

Apache POI Excel - how to configure columns to be expanded?

I am using Apache POI API to generate excel spreadsheet to output some data. The problem I am facing is when the spreadsheet is created and opened, columns are not expanded so that some long text like Date formatted text is not showing up on first…
Meow
  • 18,371
  • 52
  • 136
  • 180