How to Create Macros Using ChatGPT in Excel

This guide will explain how to create macros using ChatGPT in Excel.

Since Excel has several built-in functions and tools, it is a popular tool to use for different purposes and situations. Moreover, we can easily perform complex and difficult tasks. Furthermore, we can take it a step further and create a macro to automate certain tasks we repeatedly do. 

Although Excel allows us to easily perform calculations and data analysis, there are times when we simply have to perform the same course of action again and again. To make it easier and simpler, we can automate these repetitive tasks so we do not have to perform them step-by-step each time.

So we can automate tasks in Excel by creating macros. However, it can be a difficult task to create a macro code from scratch to automate the processes we specifically need. 

In this case, we can utilize ChatGPT which is an excellent AI answer-generating tool. So we can use ChatGPT to create macro codes for whatever task we need to automate. 

Let’s take a sample scenario wherein we need to create macros using ChatGPT in Excel.

Suppose you need to send weekly emails to all employees in the company. So you have set up all the needed information in Excel such as the email address of each employee, the subject title, and the message. Since this is a weekly task, you want to use a macro to automate the task.

However, you do not know how to create a macro code to run the task. So you utilized the ChatGPT tool and asked to make a macro that will send the email using the necessary information in the cells. And now you can simply copy and paste the macro code and run them in your worksheet whenever you need to.

Great! Now we can move on and dive into a real example of creating macros using ChatGPT in Excel.

 

A Real Example of Creating Macros Using ChatGPT in Excel

Let’s say we have a data set that shows the previous year’s list of employees and the current year’s list of employees. And the two lists are separated into two sheets. So our initial data set would look like this:

Initial dataset

 

For instance, we want to compare the previous year’s list of employees and the current year’s list of employees to find out the new employees added for the current year. Moreover, this is a task that needs to be done on a yearly bases to continuously update the list of employees for the current year. 

In this case, we have the 2022 list of employees and the 2023 list of employees. To easily determine the new employees and the employees who have left, we want to highlight the differences in red.  

Since this is a yearly task we need to perform, it would be better to automate the task by creating a macro. So a macro in Excel is a series of commands or instructions that we can use to automate tasks. Furthermore, macros are usually made using Visual Basic for Application or VBA. 

Hence, VBA Macro is a commonly known term. And we can use it to perform repetitive tasks such as formatting, data entry, forms, or even custom functions. When we have created a macro, we can then save it and use it multiple times.

However, we have never tried making macros before. And creating a macro can be a challenging task for beginners. Since a VBA Macro is a programming language, we can be hesitant about proceeding with the tool.

Hence, we can use ChatGPT to easily counter this issue. So ChatGPT is an AI language model developed by OpenAI. And it is designed to answer any questions we may ask. Moreover, it returns human-like and detailed answers or instructions which allow us to easily follow. 

Additionally, ChatGPT is currently free to use by everyone. So we simply need to sign up for an account in OpenAI to use ChatGPT freely. Once we have created an account, we can utilize ChatGPT to create macros for us to apply to our worksheet.

In this case, we want to compare the two lists found in two separate sheets and highlight the difference in red. Firstly, we must create specific and detailed instructions to paste into ChatGPT. For instance, we need to specify cell references when we have a specific cell we want to display the results.

Since we only want to highlight the differences between the two lists, we can simply specify the color we want to highlight, which in this example is red. Secondly, we can simply go to ChatGPT and paste our instructions. Then, it will return a VBA Macro code to perform the task we instructed.

Thirdly, we only have to copy the macro code and return to our worksheet to open the VBA application. Then, we can simply paste the code given to us by ChatGPT and save the macro. Next, we can run the macro whenever we need to perform the task in the worksheet.

So our final data set would look like this:

Final dataset

 

You can make your own copy of the spreadsheet above using the link attached below. 

Amazing! Now we can proceed and explain the steps of how to create macros using ChatGPT in Excel.

 

How to Create Macros Using ChatGPT in Excel

In this section, we will explain the step-by-step process of how to create macros using ChatGPT in Excel. Additionally, each step contains detailed instructions and pictures to help you throughout the process.

1. Firstly, we need to create an instruction that specifically dictates the task we want to perform. In this case, our instruction is “Write a macro that compares sheet1 and sheet2 and mark the difference in red.”

Make an instruction

2. Secondly, we will copy our instructions and paste them into ChatGPT. To do this, we can simply press Ctrl + V. Otherwise, we can also right-click and select Paste. Finally, we will press Enter to generate an answer.

Go to ChatGPT

3. Thirdly, we will copy the macro code returned by ChatGPT by clicking Copy Code. Additionally, we need to read the instructions given by ChatGPT for additional information.

Create Macros Using ChatGPT in Excel

4. Then, we will go back to our worksheet and go to the Developer tab. Next, we will select Visual Basic.

Create Macros Using ChatGPT in Excel

5. In the Microsoft Visual Basic for Application window, we will right-click our folder and select Insert. Then, we will click Module in the dropdown menu.

Create Macros Using ChatGPT in Excel

6. Afterward, we will paste the macro code we copied from ChatGPT. To do this, we can simply press Ctrl + V. Otherwise, we can also right-click and select Paste. Lastly, we will click the Save icon and close the application.

Create Macros Using ChatGPT in Excel

7. In the Save As window, we will choose Excel Macro-Enabled Workbook from the dropdown menu and click Save.

Create Macros Using ChatGPT in Excel

8. Next, we can now use our saved macro. To do this, we can simply go to the Developer tab and select Macros.

Create Macros Using ChatGPT in Excel

9. In the Macro window, we will select the macro we saved and click Run.

Create Macros Using ChatGPT in Excel

10. And tada! We have successfully created macros using ChatGPT in Excel.

Create Macros Using ChatGPT in Excel

 

And that’s pretty much it! We have successfully explained how to create macros using ChatGPT in Excel. Now you can go ahead and apply this method to your work whenever you need to create macros. 

Are you interested in learning more about what Excel can do? You can now use the various other Microsoft Excel formulas available to create great worksheets that work for you. Make sure to subscribe to our newsletter to be the first to know about the latest guides and tutorials from us.

Get emails from us about Google Sheets.

Our goal this year is to create lots of rich, bite-sized tutorials for Google Sheets users like you. If you liked this one, you'll love what we are working on! Readers receive ✨ early access ✨ to new content.

0 Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like