VBA Training Series – How to Write Your First Macro (Part 1 of 3)

Macros & VBA Training Series Part 1:

Writing Your First Macro & The Excel Object Model

Double-click video to view in Full Screen HD.

Download the file used in this video:

My-First-Macro-Reference-Common-Objects.zip

Macros & VBA Training Series

Enroll for FREE

The video above is the first in a 3-part training series. Can I send you the next two videos?

Please click the link below to enroll in the free training. I will send you video #2 in just a few days.

Please click the big green button above to register for the free training series.

Jon Acampora Circle MVP Profile 2019

About Me

Welcome to Excel Campus!  I am excited you are here!

My name is Jon Acampora and my goal is to help you learn Excel to save time with your job and advance in your career.  I've been an avid Excel user and VBA developer for 10+ years.  I am also a Microsoft MVP.  When I'm not looking at spreadsheets, I get outdoors and surf. 🙂

What Process Do You Want To Automate in Excel?

Please leave a comment below with your answer, and any questions.  Thanks!

1,683 comments

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

  • Hi Jon,

    I will have to read somebody else’s VBA code and enter comments for the next technical person that works on it.

    It’s 10,000 lines of code and I only wrote macros by recording plus entering and modifying code found on line.

    It sounds daunting so I better learn as much as I can…and quickly 😉

    G

  • I am Trying to write a nutritional database in Excel 2007. I wish to be able to copy and paste say recipes. Therefore I would have to enter all the ingredients quantities and calories ect copy this to another place or to another worksheet then delete the excising data.

  • very good explanation and examples. I like the way you go step by step. It helps for better comprehension of the topics. Great job -)

  • Hi,

    I would like to learn advance macros using VBA language. Currently, I have
    executed macros on an intermediate level; but I am a beginner in writing the
    VBA language. I do have programming experience using COBOL II.

  • Hi Jon,

    This was my very first introduction to VBA, I had seen the screen before and always thought it was beyond me. I really enjoyed the way you explained everything and look forward to the next video. Amazing that there are people like you out there willing to give your time to help others, thanks so much.

    M

  • Enjoyed the love and kindness that flows effortless when you give your talent back to others. You are being blessed by
    being a blessing to others. You are obeying the word by being a giver of your knowledge. It is better to give than receive.

  • I like the way you go step by step.
    It helps for better understanding of the topics

    very good explanation and example

  • Video 1 is awesome, as a beginner its very easy for me to catch up on your training, I appreciate your way of teaching from the basic with all the concepts explained clearly. Thank you for making us feel VBA is easy for learning as a beginner. kindly send me the link for the consecutive videos.

  • Hello there;
    my question is how to write a macro that search for a specific word or verb in one column and will copy this particular word into another column of the same row and in the same worksheet? thank you

  • I would like you to demonstrate a macro that dynamically identifies the populated data area in a worksheet and then copies and pastes the data from that area to the bottom of the data in another worksheet. ie combining the 2 sets of data from 2 separate worksheets into 1 worksheet where the size of the data in each sheet must first be identified.

  • Hi Jon.
    When entering data in cells A1 through A10 after pressing return I would like the cursor to jump to cell A2 so that I could continue entering new data.
    Your teaching method is good. Thanks for the help…HB

  • Hi John, I always like an instructor using visualization techniques and analogies.
    My intention is to create a list of dropdown questions for a service call which will identify one or two individuals qualified for the call using rows for the individuals and many, many columns of details pointing to the dropdown questions. Hopefully this will be a fun project for me and I learn something new. I do have some abilities but am working from days long gone writing in Motorola processors and GW Basic code.

  • Thanks for the lecture. Very help.

    I want a VBA code to post from a cash book to ledger accounts. Basically want to use excel to maintain a simple set of account.

  • Really helpful step by step on the hows and whys that is useful for beginners and practical when applying in the workplace. Thank you!

  • As an Consultant, I have a lot of things to manage and keep track of. Loads and loads of data.

    What I need is a Content Management system, but all I have is Excel. It seems as if VBA will help me get something created until which time a Learning Content Management System (LCMS) is procured.

    I have some VBA experience, but as with anything you do not use daily, I’m pleased with the first video. Very clean. You articulate well, have a nice pace, and display what is relevant. I respect that very much.

    Thanks.

  • This is exactly what I needed. I pick stuff up pretty quick, but I really needed someone to just break down the foundation of what’s going on here. Once I understand the language of something, I can typically run with it. I am in the lending industry, and I use an Excel Workbook that I’ve been dialing in for a long time. I use it to do all of my analysis when qualifying a borrower. Getting some Macro’s involved will really get the job done the way it should be. Most grateful! 🙂

  • We always get data from a database, with a lot of unnecessary information, so i want to prepare this data in a more readable form

  • Hi Jon,
    I would like to learn how to transfer different columns like (A,C,L,P) to another spread sheet using VBA.
    Can you help me if it’s posible. I’ll appreciate your help,
    Thanks,
    Sean

  • Hi Jon,

    Thanks for the first video you sent me. Your teaching method seems quite easy to follow. I have been trying to learn macro for a while but is hardly making progress. I think I can improve with your teaching. I’m very much looking forward to the other videos in the series. Please can you send them.

    David

  • I am using a Surface Pro4, and the function key is somewhat different. E.g Invoke a VBA editor is Fn+Alt+F11

    I am thinking to analyze a stream of data via the TCPIP port from a trading application, and display the dynamic result in Excel. I don’t know how difficult it is!

    • Hi Richard,
      The Fn key can be locked on the Surface Pro Type Cover. Here is an article that explains how. Scroll down on that page to the section on “Lock keys in function mode”.

      In terms of your project, I don’t have experience with extracting data from the TCPIP port. As long as you can get the data into Excel, then you should be able to analyze it. I hope that helps.

  • I was looking for a video on how to copy data from one worksheet to another worksheet if a certain Number or letter is met in a different column. Hopefully I have explained it correctly and ex below.

    if G6 on sheet one is = to the letter “D” then copy H6(sheetOne) to A1 on sheet two.

  • Very useful video. Concepts are explained in easy to understand manner. Thank you very much… Regards S

  • Hi Jon,
    We have data scattered across 2 workbooks. One workbook contains, Names of employees & their holiday details i.e. dates & type of holiday. (this is exported from a tool). The other workbook contains name of tasks / projects on which they have worked on on a specific date. We would like to merge these 2 workbooks, so that we have entire data available in one worksheet. Would really appreciate, if you could provide some pointers on how to automate this? Regards Sunil

  • Hi John

    Im a beginner in VBA, i need your assistance with a VBA code that will select multiple criteria and save as a sheet name, i got it right with one word “Black” but i need may 50 different names Black,blue,red,yellow,pink,etc see the code below

    Selection.AutoFilter
    ActiveSheet.Range(“$A$1:$BA$11028”).AutoFilter Field:=3, Criteria1:= _
    “Black”
    Range(Selection, Selection.End(xlDown)).Select
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Copy
    Workbooks.Add
    ActiveSheet.Paste
    Range(“C2”).Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = “Black”
    Sheets(“Sheet1”).Select
    Sheets(“Sheet1”).Name = “Black”

  • Hi, great video. I’d like to build a portable macro to refine headers that dumped from a database export tool. By refining the headers I mean centering, change font to bold, apply wrap-text and then freezing the sheet pane on the header row. Thanks!

  • Question:

    Jon,

    I have inquired about automating a process where a Pivot Table’s data source is on a separate sheet from the Pivot Table. I was tasked to read from each row on another data source sheet (all in same workbook) containing search criteria, and located the data in the Pivot Table. Then, if the search criteria is found in the PT, then copy the entire PT row out to another sheet to a next available row in a table.

    I have not been successful in getting answers to this particular challenge where the process is executed correctly. Can you help? Note I’m a somewhat experienced professional. I just have not done something like this before.

    The manager is obsessed with PT’s, and finds solutions for her tasks primarily using PT’s.

  • Hi Jon, so the video was informative. But I had an issue: Worksheets(“Sheet2”).Select did not work. The wording did auto complete and the syntax info did appear, but the intelligent menu did not appear. When I F8 through, it bugged out on that line of code.

    Sheet2.Select by itself did work. Then I removed that and went back retyped the above and for some reason it (worksheets) did work. That was a bit frustrating because I am sure that the syntax was correct the first time. Any advice?

  • Hello jon

    I m beginner in macro..
    Video is gud and way of teach is awsm.

    That time I don’t know what work will be do with macro.

  • Hello Sir

    Thanks for sharing, very helpful tuturial.

    Sir please send me in my email the next two video tuturial,

    thanks in advance…

  • Thank sir about your explain in your email
    But i need help you to problem solving that i have,is way vba make search add (search dinamis)in the userform

    Thanks