How to use ChatGPT to process excel

To process excel with ChatGPT, the main tools we need to use are ChatGPT and vba code.

VBA code is a programming language for Microsoft Office software for Excel, Word, PPT.

It allows users to realize functions such as automation, customization and data processing by writing some simple instructions and operations.

Just like you write computer programs, you can use VBA code to control Microsoft Office software to perform various tasks.

Such as automatically filling in forms, reading and processing data, creating custom toolbars, etc., allowing you to complete your work more efficiently.

How to do it?

The first step is to prepare the data

I just let chatgpt help me generate a simple set of data, which is convenient for example demonstration:

In the second step, chatgpt generates VBA code

Copy the data generated by chatgpt directly to the input box, and let chatgpt generate VBA code based on these data:

 

The third step is to open the excel developer tool

Click Developer Tools→Visual Basic in the toolbar to enter the VBA program panel

 

Right-click "sheet 1" → "Insert" → "Module" in the upper left operation bar to enter the module code page

The fourth step, enter the VBA code and run

Copy the VBA code generated by chatgpt to the panel above:

 

Click "Run" → "Run Subprocedure/UserForm": 

Go back to the excel page, and you can see that the table is created: 

In addition to creating tables, you can also use chatgpt combined with VBA codes to perform various operations, such as data processing, data analysis, and so on.

Tell chatgpt your needs, and let chatgpt generate the corresponding VBA code for you directly.

To give an example to demonstrate, the following is a table composed of 25 sets of data randomly generated by chatgpt:

Next, our operations are based on this form:

1. Add color

The above table looks very monotonous as a whole. We can do a simple process first to add a color to the table, such as adding blue to the first row, adding orange to those whose total salary is more than 10,000, and adding yellow to those whose total salary is less than 10,000.

Write prompt:

Please write a vba code to set the first row of columns A to E in the table as light blue, and start from the second row, set the row where the value in column E is greater than 10000 to orange, and the row where the value is less than 10000 to be yellow

Copy it to excel and run it to see the effect: 

It can be seen that excel has performed the operation, but the color is also added after the column E from the 2nd to the 26th row appears, which we don't need.

So we directly tell chatgpt the requirements, and let chatgpt regenerate the vba code for us:

 Copy the code to excel and run it to see the effect:

This has met our expected standard, no problem at all!

2. Make a histogram

Do data analysis on chatgpt, such as histograms and pie charts. To be honest, I have forgotten how to operate these in excel tables.

But it doesn't matter, after having chatgpt, we don't need to operate step by step, we just need to bring the demand to chatgpt.

for example:

Please write a vba program to generate a histogram in the current workspace, count the data from B2 to B26 and the data from E2 to E26, and divide the data into 3 intervals according to the data from B2 to B26, of which 20 to 25 is a interval, 26 Up to 30 is an interval, greater than 30 is an interval, and the ordinate of each interval is the average value of the values ​​in column E corresponding to the interval

 

Copy it to excel and run it to see the effect: 

It can be found that the histogram is generated as required, but one more column is generated for each interval. We can directly delete the data in the third column from the data in the upper left corner of the histogram to obtain a single column chart. 

We can also directly send the problem to chatgpt, let chatgpt help us solve it: 

Copy it to excel to run to see the effect: 

Similarly, if we want to make a pie chart, we can just throw the demand directly to chatgpt:

(Before copying to excel, remember to save the previous module and create a new module) 

See the effect: 

The above is about the specific operation of using chatgpt to do excel.

The principles and steps are basically these, and there are many interesting ways to play to explore, let your imagination run wild!

Precautions:

When using vba to operate excel, remember to back up the original data in advance, because when using vba to modify, excel cannot perform the return operation, so once the vba code makes an error and all our data is changed, the original data will also be lost.

Guess you like

Origin blog.csdn.net/qq_16027093/article/details/131367207