In this post, we will talk about various ways to integrate DeepSeek into MS Excel. DeepSeek has a public API which makes it easy to use DeepSeek in MS Excel.

How to Get DeepSeek API
- You can sign up for an account on DeepSeek's platform by visiting platform.deepseek.com and then create an account using your email address.
-
Click the
Top up
button on the left side of the menu and then select the amount you wish to add. Next choose a payment method and enter your details to complete the payment.If you get an error while using debit/credit card as a payment method that your country is not supported, you can use Paypal and then choosePay with Credit or Debit Card
option. You don't need paypal account for the same. - Click the
API keys
button on the left side of the menu and then click onCreate a new API key
button. The API key will look like the following.
sk-xxxxxxxxxxxxx
Method 1 : Excel Plugin for DeepSeek
You can download the Excel plugin for DeepSeek by clicking on Download button. In Excel, a plugin is referred to as an add-in. Don't get confused. Plugin and add-in are essentially the same in MS Excel.
When you download add-in or macro file from internet, Microsoft blocks them from running and shows the source of this file is untrusted. You need to follow the steps below to make it working.
- Go to the folder where the downloaded add-in file is located.
- Right-click the file and choose Properties from the menu.
- At the bottom of the General Tab, select the Unblock checkbox under security option and then click OK.
Refer the following steps to install DeepSeek add-in in MS Excel.
- Open Excel and click on the
File
tab in the ribbon. - Click on
Options
and then selectAdd-ins
from the left-hand menu. - In the
Manage
drop-down menu at the bottom of the screen, selectExcel Add-ins
and click on theGo
button. - Click on the
Browse
button and locate the add-in file that you downloaded. - Select the add-in file and click on the
OK
button. - You should see the name of the add-in file in the
Add-Ins
dialog box. Check the box next to the add-in name to activate it. - Once you are done with the above steps, a new tab called
DeepSeek
should be visible in your Excel workbook.
Follow the steps below to use DeepSeek add-in for MS Excel.
- Open a new or existing MS Excel Workbook
- Enter text you want to ask DeepSeek in any cell
- Click on DeepSeek Tab > DeepSeek Assistant.
- Enter your API Key and select Model Type.
- Select the cell in which you entered text in step 2.
- Output will be generated and will appear within a few seconds.
- When you want DeepSeek to run on multiple cells, you can use the
DeepSeek
function. See the details in the next section.
This add-in can generate both text and images and has the following features:
- Text Generation
- Multi-turn Conversations (Chat)
- Fill Missing Data
- Extract Key Information
- Translate Text
- Learn Excel Formulas with DeepSeek
- Data Insights
- Building Question and Answering System
Text Generation
The DeepSeek
function generates text output based on a search query using DeepSeek.
DeepSeek(text, [word_count])
- text : Text you want to search
- word_count : Optional. Specify the maximum number of words for the output generated by DeepSeek.
=DeepSeek("First President of US")
If you want to limit the response from DeepSeek to a maximum of 2 words, specify '2' as the second argument of the function. For example, =DeepSeek("First President of US", 2)
.
Sometimes non-english letters do not get displayed correctly in the response coming from DeepSeek API due to UTF-8 encoding issue. To fix this issue you can apply the CleanMsg
function to the output of DeepSeek or any other function. Please refer to the example below.
=CleanMsg(DeepSeek("Write a post about 'Good morning' in Spanish"))
Chat Conversations
By default when DeepSeek API answers your question, it does not remember your previous conversations. It is important for AI to remember previous conversations in order to better understand you so that it can improve its responses each time.
The function DeepSeek_Chat
is used to activate multi-turn conversations.
DeepSeek_Chat(text, [reset])
- text : Text you want to search
- reset : Optional. Set it to TRUE to start/reset chat session.
=DeepSeek_Chat("2+2") =DeepSeek_Chat("square of it")
"**Solution:**
To find the square of the sum \(2 + 2\), follow these steps:
1. **First, calculate the sum:**
\[
2 + 2 = 4
\]
2. **Now, square the result:**
\[
4^2 = 4 \times 4 = 16
\]
**Final Answer:**
\[
\boxed{16}
\]"
It is recommended to set the second argument of the function reset
as TRUE when you do not need DeepSeek to recall your prior conversations.
Data Insights
Please follow the steps below to generate data insights or find hidden patterns in your data with this plugin.
- Click on the
Generate Insights
button in the DeepSeek tab on the ribbon in Excel. - In the message dialog box, select cells containing data (including the header) and then click "OK". For example, A1:D101.
- Wait for the insights generated from DeepSeek API.
- In the message dialog box, select a cell where the output will be saved. For example, F2.
- Select "yes" or "no" if you want the output to be populated in multiple rows or a single row.
The function DeepSeek_Insights
is used to generate insights from data.
DeepSeek_Insights(rng_data, [prompt])
- rng_data : Specify cells containing data (including the header).
- prompt : Optional. Provide specific information you want about the data.
=DeepSeek_Insights(A1:D101,"Generate Top 5 Insights")
Translate with DeepSeek
The function DeepSeek_Translator
is used to translate text. Just enter the text you want to translate and the language name, it will give you translations.
DeepSeek_Translator(text, language)
- text : Specify the cell that contains text you want to translate.
- language : Name of language. E.g. Spanish, French etc.
=DeepSeek_Translator("Hello, How are you?", "german")
Extract Key Information
The DeepSeek_Extractor
function can be used to fetch key information such as name, location etc from the text.
DeepSeek_Extractor(prompt, keyword)
- prompt : Specify the cell that contains text from which you want to extract key data.
- keyword : Keyword can be name, place, organization etc.
Suppose you have text "Dave went to New York for studies" in cell B2. You want to extract name and location from the text. Enter the following formula in cells C2 and D2.
=DeepSeek_Extractor(B2,"name") =DeepSeek_Extractor(B2,"location")
Fill Missing Data
The DeepSeek_FillData
function can be used for a variety of purposes. See some of the real-world use cases below.
- Sentiment Analysis You can label positive/negative/neutral sentiments on customer feedback data. You just need to provide a few labels in first argument of the function.
- Industry/Sector Classification You have companies name and wish to find out their industries/sectors.
- Text Patterns Extraction You have text data which contains both character and numeric values. By using this function, you can extract numeric values from the text.
DeepSeek_FillData(rng_existingdata, rng_fill)
- rng_existingdata : Range of training data
- rng_fill : Specify the cell that needs to be filled in.

Building Question and Answering System
The DeepSeek_QnA
function is used to build a question and answering system. You input a paragraph or a text document along with your question and it helps you find the relevant answer within that text. It can be useful for tasks like quickly extracting information from large text without the need to manually search through the text.
DeepSeek_QnA(query, passage)
- query : Specify the cell containing a question.
- passage : Specify the cell containing a large text.
=DeepSeek_QnA(B6, B3)
You can also specify multiple cells for a passage like in the example below.
=DeepSeek_QnA(A2, A3:A10)
Learn Excel Formulas with DeepSeek
The DeepSeek_Explain
function helps you explain any Excel formula.
DeepSeek_Explain(cell_formula, [detail])
- cell_formula : Cell that contains an Excel formula that you want DeepSeek to explain to you.
- detail : Optional. Default value is TRUE. Set FALSE if you want less verbose resonse.
Let's say you have a formula in cell B2: =VLOOKUP(B2,$B$2:$D$5,2,FALSE). If you enter this formula =DeepSeek_Explain(B2) in cell C2, it will provide an explanation for the VLOOKUP function.
How to Handle Large Number of Prompts
Suppose you have more than 100 prompts distributed across 100 cells in an Excel sheet and you want to get answers for each prompt using DeepSeek. If you attempt to do this all at once by dragging the DeepSeek function to 100 rows, it may cause Excel to slow down or show errors because it can't handle so many requests together.
To fix this issue, you can ask one question at a time instead of sending all the questions to DeepSeek at once. Then move on to the next question and repeat the process. In the code below, we assumed prompts starting from cell B3.
Sub DeepSeekLoop() Dim ws As Worksheet Dim promptColumn As String Dim promptRng As String Dim startRow As Long Dim cell As Range Dim result As Variant Dim lastRow As Long ' Set the active sheet as the working sheet Set ws = ActiveSheet ' Set the column having prompts. For e.g., prompts starting from cell B3 promptColumn = "B" startRow = 3 ' Find the last row in column lastRow = ws.Cells(ws.Rows.Count, promptColumn).End(xlUp).Row ' Loop through cells to the last row promptRng = promptColumn & startRow & ":" & promptColumn & lastRow For Each cell In ws.Range(promptRng) ' Check if the cell is not empty If Not IsEmpty(cell.Value) Then ' Handle errors and continue with the next iteration On Error Resume Next ' Call the DeepSeek function with the cell value result = Application.Run("DeepSeek", cell.Value) ' If there was an error, skip to the next iteration If Err.Number <> 0 Then Err.Clear On Error GoTo 0 GoTo NextCell End If ' Reset error handling On Error GoTo 0 ' Paste the value back into the adjacent column cell.Offset(0, 1).Value = result End If NextCell: Next cell End Sub
Run the macro by pressing Alt+F8, selecting the macro DeepSeekLoop
and clicking the Run button.
If you are still getting errors, you can add a wait time between each iteration. You can use the Application.Wait Now + TimeValue("00:00:01")
code immediately after NextCell: in the code above to wait for one second before the next iteration.
If you also want to use CleanMsg
function, use this Application.Run("CleanMsg", Application.Run("DeepSeek", cell.Value))
Method 2 : Excel Macro for DeepSeek
This method is simply an alternative to using an add-in. It contains VBA code that fetches responses from DeepSeek using the API and places them into Excel. It also cleans the responses from DeepSeek and puts them in a structured format to maintain formatting.
Sub DeepSeek() Dim request As Object Dim response As String Dim text, API, api_key, DisplayText, error_result As String Dim status_code As Long Dim cellr As Range Dim prompt, rng As Range 'API Info API = "https://api.deepseek.com/chat/completions" api_key = "sk-xxxxxxxxxxxxxxxxxx" If api_key = "" Then MsgBox "Error: API key is blank!" Exit Sub End If Set prompt = Range("B3") Set cellr = prompt.Offset(1, 0) Set rng = Range(prompt.Offset(1, 0), prompt.Offset(2000, 0)) rng.Clear 'Input Text If prompt.Value = "" Then MsgBox "Error: Cell " & prompt.Address(RowAbsolute:=False, ColumnAbsolute:=False) & " is blank!" Exit Sub End If text = Replace(prompt.Value, Chr(34), Chr(39)) text = Replace(text, vbLf, " ") 'Create an HTTP request object Set request = CreateObject("MSXML2.XMLHTTP") With request .Open "POST", API, False .setRequestHeader "Content-Type", "application/json" .setRequestHeader "Authorization", "Bearer " & api_key .send "{""model"": ""deepseek-chat"", ""messages"": [{""content"":""" & text & """,""role"":""user""}]," _ & """temperature"": 1}" status_code = .Status response = .responseText End With 'Extract content If status_code = 200 Then DisplayText = ExtractContent(response) Else DisplayText = ExtractError(response) End If 'Put response cellr.Value = DisplayText 'Split to multiple rows Call SplitTextToMultipleRows(cellr) rng.WrapText = True 'Clean up the object Set request = Nothing End Sub Sub SplitTextToMultipleRows(cell As Range) Dim splitArr() As String Dim delimiter As String delimiter = "\n" splitArr = Split(cell.Value, delimiter) For i = LBound(splitArr) To UBound(splitArr) x = splitArr(i) If Left(Trim(x), 1) = "=" Then x = "'" & x End If cell.Offset(i, 0).Value = Replace(x, "\""", Chr(34)) Next i End Sub Function ExtractContent(jsonString As String) As String Dim startPos As Long Dim endPos As Long Dim Content As String ' Find "choices" array startPos = InStr(jsonString, """choices""") If startPos = 0 Then ExtractContent = "Error: 'choices' not found" Exit Function End If ' Find "message" within the first choice startPos = InStr(startPos, jsonString, """message""") If startPos = 0 Then ExtractContent = "Error: 'message' not found" Exit Function End If ' Find "content" key inside the first "message" startPos = InStr(startPos, jsonString, """content""") If startPos = 0 Then ExtractContent = "Error: 'content' not found" Exit Function End If ' Move startPos to start of content text startPos = startPos + Len("""content"":""") ' Find the closing quote for the content text endPos = InStr(startPos, jsonString, """") If endPos = 0 Then ExtractContent = "Error: End of 'content' not found" Exit Function End If ' Extract the content Content = Mid(jsonString, startPos, endPos - startPos) ' Replace escaped quotes Content = Replace(Content, "\""", Chr(34)) ' Fix for Excel formulas If Left(Trim(Content), 1) = "=" Then Content = "'" & Content End If ' Remove unnecessary line breaks Content = Replace(Content, vbCrLf, "") Content = Replace(Content, vbLf, "") Content = Replace(Content, vbCr, "") ExtractContent = Content End Function Function ExtractError(jsonString As String) As String Dim startPos As Long Dim endPos As Long startPos = InStr(jsonString, """message"": """) + Len("""message"": """) endPos = InStr(startPos, jsonString, """") If startPos > Len("""message"": """) And endPos > startPos Then ExtractError = Mid(jsonString, startPos, endPos - startPos) Else startPos = InStr(jsonString, """code"": """) + Len("""code"": """) endPos = InStr(startPos, jsonString, """") If startPos > Len("""code"": """) And endPos > startPos Then ExtractError = Mid(jsonString, startPos, endPos - startPos) Else ExtractError = "Unknown error" End If End If End Function
- Press Alt+F11 to open the VBA editor.
- Click Insert > Module to create a new module.
- In the module, copy and paste the VBA code mentioned above.
- You need to enter your API key in the code above in the variable api_key. This is the same secret key which we obtained in the previous step.
- Enter your question (prompt) in cell B3 and then follow the steps below.
- Specify
deepseek-reasoner
in the model argument to use DeepSeek-R1 model. - Close the VBA editor and then run the macro by pressing Alt+F8 or by going to the Developer tab > Macros and select the macro
DeepSeek
and hit Run button.
Method 3 : Excel Function for DeepSeek
You can also run DeepSeek as an excel function. The benefit of running it as function is that you can paste it down on multiple cells.
Function DeepSeekAI(text As String, Optional word_count As Long = 0) As String Dim request As Object Dim response As String Dim API, api_key, DisplayText, error_result As String Dim startPos, endPos, status_code As Long Dim rng As Range 'API Info API = "https://api.deepseek.com/chat/completions" api_key = "sk-xxxxxxxxxxxxxxxxxxxxxxxx" 'Input Text If word_count > 0 Then text = text & ". Provide response in maximum " & word_count & " words" End If text = Replace(text, Chr(34), Chr(39)) text = Replace(text, vbLf, " ") 'Send request to API Set request = CreateObject("MSXML2.XMLHTTP") With request .Open "POST", API, False .setRequestHeader "Content-Type", "application/json" .setRequestHeader "Authorization", "Bearer " & api_key .send "{""model"": ""deepseek-chat"", ""messages"": [{""content"":""" & text & """,""role"":""user""}]," _ & """temperature"": 1}" status_code = .Status response = .responseText End With 'Parse response from API If status_code = 200 Then DisplayText = ExtractContent(response) Else DisplayText = ExtractError(response) End If If word_count > 0 And Right(DisplayText, 1) = "." Then DisplayText = Left(DisplayText, Len(DisplayText) - 1) Else DisplayText = DisplayText End If 'Return result DeepSeekAI = DisplayText End Function Function ExtractContent(jsonString As String) As String Dim startPos As Long Dim endPos As Long Dim Content As String ' Find "choices" array startPos = InStr(jsonString, """choices""") If startPos = 0 Then ExtractContent = "Error: 'choices' not found" Exit Function End If ' Find "message" within the first choice startPos = InStr(startPos, jsonString, """message""") If startPos = 0 Then ExtractContent = "Error: 'message' not found" Exit Function End If ' Find "content" key inside the first "message" startPos = InStr(startPos, jsonString, """content""") If startPos = 0 Then ExtractContent = "Error: 'content' not found" Exit Function End If ' Move startPos to start of content text startPos = startPos + Len("""content"":""") ' Find the closing quote for the content text endPos = InStr(startPos, jsonString, """") If endPos = 0 Then ExtractContent = "Error: End of 'content' not found" Exit Function End If ' Extract the content Content = Mid(jsonString, startPos, endPos - startPos) ' Replace escaped quotes Content = Replace(Content, "\""", Chr(34)) ' Fix for Excel formulas If Left(Trim(Content), 1) = "=" Then Content = "'" & Content End If ' Remove unnecessary line breaks Content = Replace(Content, vbCrLf, "") Content = Replace(Content, vbLf, "") Content = Replace(Content, vbCr, "") ExtractContent = Content End Function Function ExtractError(jsonString As String) As String Dim startPos As Long Dim endPos As Long startPos = InStr(jsonString, """message"": """) + Len("""message"": """) endPos = InStr(startPos, jsonString, """") If startPos > Len("""message"": """) And endPos > startPos Then ExtractError = Mid(jsonString, startPos, endPos - startPos) Else startPos = InStr(jsonString, """code"": """) + Len("""code"": """) endPos = InStr(startPos, jsonString, """") If startPos > Len("""code"": """) And endPos > startPos Then ExtractError = Mid(jsonString, startPos, endPos - startPos) Else ExtractError = "Unknown error" End If End If End Function
Make sure you enter your API key highlighted in bold above.
Follow the steps 1 to 4 in the previous section "How to use VBA Code". Once you are through with these 4 steps, type =DeepSeek(B3)
in any cell. Here B3 refers to the cell wherein your prompt (question) is placed.
How to Use DeepSeek to Write Excel Formulas
You can use the above add-in or macro and ask DeepSeek to act like an excel tutor and help you in writing Excel formulas.
=DeepSeek("Excel formula for 'Pass' if a value in cell F5 is less than 70, else 'Fail'")
How to Use DeepSeek to Write VBA Code
It also works well for advanced excel concepts like macros. It can write VBA code for you. Writing VBA code has never been easier before with DeepSeek.
=DeepSeek("Write VBA code to apply filter on sheet1 and paste filtered rows to sheet2")
How to Fine Tune DeepSeek Response
You would find temperature
parameter in the VBA code. It lies between 0 and 2. Use 0 value for coding or math related problems. Use default value of 1 for data analysis and 1.5 for creative writing.
Share Share Tweet