Automating Excel with Macros

Automating Excel with Macros

Many of us need Excel files with some random text to work with. We can learn to work with many of the Excel functions and formulas only when we have Excel sheets with data. Manually creating data on an Excel sheet will take a lot of time and effort. How about automating it with macros? In this project, we’ll create some random text in an Excel sheet using macros.

As usual, I open a new Excel sheet and save it as an xlsm file. Then, I give Alt+F11 to go to the Visual Basic coding area within the Developer tab. Now, I open a module.

Okay, let’s go to chat GPD now to give it a prompt. Forget about all the previous instructions. Imagine that you are an expert in creating Excel macros. Can you write an Excel macro to generate dummy text on a sheet from A1 to F20? The first column should contain unique names of other people. The names should be people’s names like Ram, Peter, Venkat, Angel, etc. Try not to repeat the same names. The next five columns should contain their marks scored in five subjects, all in two digits. All of them can be random, but include column headers suitably. I must be able to generate this text in more than one sheet of an Excel file.

Okay, we have the code ready. Let’s copy this. Now, I go to the VB module and paste in the code. I save it. Alt+F11 to go back to the Excel working sheet. Alt+F8 to open the macros. Now, I run the macro. There you go, the random text is ready.

Let me open another sheet within this file and I run the macro on this sheet as well. Okay, when I run the code in the second sheet, the macro is not responding to that. So let me go back to chatGPT. I am not able to generate random text in the second sheet. Change the code so that I can generate random text on more than one sheet within a file.

Okay, chatGPT has revised the code. Now, let me copy-paste it into the Excel module. Let’s see if this works. Yes, now it works. Let me try it on another sheet. Yes, it works fine now.

So, this is how you should do when chatGPT makes some mistakes. Clearly point out the mistake descriptively and ask what you want from chat GPD.

ChatGPT 5: The Ultimate Game Changer of the AI Industry
Older post

ChatGPT 5: The Ultimate Game Changer of the AI Industry

Newer post

Learn Macros Functions and Formulas

Learn Macros Functions and Formulas