Skip to main content

Posts

Showing posts from March, 2023

Bring ChatGPT to Excel using VBA

In this blogpost we will show how to bring ChatGPT into Excel and chat with the OpenAI's ChatGPT from the comfort of your excel sheet. To do this we can use the following code Sub GetChatGPTResponse() Dim apikey As String  apikey = "Your aPI Key" ''''''''''get you API key from openAI account and paste it here.  Dim prompttext As String prompttext = Home.Range("B9").Text   ''Change the cell reference for your question as per your needs  Dim modelname As String  modelname = "text-davinci-002"     Dim url As String url = "https://api.openai.com/v1/engines/" & modelname & "/completions"     Dim xmlhttp As Object Set xmlhttp = CreateObject("MSXML2.XMLHTTP")     Dim requestData As String requestData = "{""prompt"": """ & prompttext & """, ""max_tokens"":1000, ""temperature"...