How To Create a Class Module in VBA

Поделиться
HTML-код
  • Опубликовано: 3 окт 2024

Комментарии • 87

  • @jdub-replicant
    @jdub-replicant 8 лет назад +18

    this was one of the most simple and clearly understandable explanations of classes in VBA ever. also thank you for adding music in the background. it helped drive the video along. thanks much for posting!

  • @egzonjack3957
    @egzonjack3957 3 года назад

    Ich küss doch dein herz für dieses video

  • @tarba2ha-885
    @tarba2ha-885 10 месяцев назад

    Man, this sound track is awesome, Gr8 job!

  • @EricHartwigExcelConsulting
    @EricHartwigExcelConsulting 3 года назад

    Just found this video and really enjoyed it.
    I have been trying to wrap my head around class modules for years and really helped to explain how they work and can be used!
    Thank you so much for creating/sharing this video!

    • @BusinessProgrammer
      @BusinessProgrammer  3 года назад +1

      Glad You found it helpful Eric, given its five years old, I think it's going to be time soon for me to do a remake of this video.

    • @EricHartwigExcelConsulting
      @EricHartwigExcelConsulting 3 года назад +1

      @@BusinessProgrammer I subscribed to your channel so I will be sure to be notified when you post new videos. Really looking forward to watching all of your other videos as well.

  • @GNAFerreira
    @GNAFerreira 6 лет назад +2

    Wow, wish I had watched this video before: I could have done so many things more efficiently if I knew OOP in VBA. Thanks a lot for the great video!!

  • @romariodaniel1152
    @romariodaniel1152 2 года назад

    you are a monster dude, thank you. no long drawn out convoluted explanation

    • @BusinessProgrammer
      @BusinessProgrammer  2 года назад +1

      Glad you found it helpful, I remember "back in the day" trying to find out the purpose of class modules, and not being able to get a straight answer.

    • @romariodaniel1152
      @romariodaniel1152 2 года назад

      @@BusinessProgrammer definitely and vba has given me the confidence i needed to do other coding languages, truly amazing stuff

  • @directiva108
    @directiva108 5 лет назад +1

    The music totally brings it to a Chad level.

  • @mynorrubio5116
    @mynorrubio5116 5 лет назад

    Thank you! I finally understand how to create and use a class module in VBA, great video!

  • @ahmedhossam6595
    @ahmedhossam6595 7 лет назад +3

    "The magic of objects!!" Nice!

  • @ashokanselliah9571
    @ashokanselliah9571 4 года назад

    Great video to learn at first time about class module. Hugely helpful Sir.

  • @Ryan-zz6hh
    @Ryan-zz6hh 5 лет назад +1

    This is fantastic and super clear. Thank you, Sean!

    • @BusinessProgrammer
      @BusinessProgrammer  4 года назад

      Thanks for the feedback Ryan, sorry for the the "slight" delay in getting back to you.

  • @RobertDonaldDuck
    @RobertDonaldDuck 3 года назад

    Without that noise in the background a great video. I had to switch the sound off as otherwise I could not focus on the content.

    • @BusinessProgrammer
      @BusinessProgrammer  3 года назад

      Yes, I don't add music to my videos any more, can't change this one though

    • @RobertDonaldDuck
      @RobertDonaldDuck 3 года назад

      @@BusinessProgrammer But thank you for your prompt response! Great ...

  • @AlfredoBravo
    @AlfredoBravo 4 года назад

    Hola Sean, es perfecta tu explicación, sin dar tantas vueltas y queda muy claro como crear un módulo de clase.
    Me recuerda a lo similar que es "crear una tabla y sus campos" con sus parámetros en una base de datos como Mysql.
    De nuevo, muchas gracias, y aunque puedo escribir en inglés esta vez opté por lo mas fácil para mi. ;-)
    Saludos desde Argentina.

    • @BusinessProgrammer
      @BusinessProgrammer  4 года назад

      Hola alfredo
      De nada, me alegro de que te haya gustado.
      tienes razón, es como tablas y campos.
      Si mi español es malo, culpa al traductor de Google ;-)

  • @Meolimo
    @Meolimo 5 лет назад

    awsome !
    Thanks from Montréal (Quebec)

  • @noambrand
    @noambrand 4 года назад

    Excellent explanation, I finally understood :)
    100/100

  • @vikassolanki297
    @vikassolanki297 5 лет назад

    simple and clear example

  • @chrisbezant4760
    @chrisbezant4760 4 года назад +1

    You don't need the music, it masks your soft voice. The technical content is good.

    • @BusinessProgrammer
      @BusinessProgrammer  4 года назад

      I know, I've stopped using music, i'm afraid it's encoded into this tutorial.

    • @tymussh
      @tymussh 4 года назад

      @@BusinessProgrammer Agreed. Music creates problems/distraction (specially when listening) or as long it it is in very low volume. But the concept was presented very nicely..... at least I understood when various other videos posted by others, I didn't understand clearly.

    • @davidunger7425
      @davidunger7425 3 года назад

      I'm glad you've decided to stop using music, as I find it very distracting when trying to concentrate on a complex topic like this. But other than that, an excellent presentation, looking forward to more of the same. Thanks.

  • @YourXLNerd
    @YourXLNerd 7 лет назад

    thanks sean! cool accent - i havent done vba in a while and thought maybe i should have a more OOP approach this time - this helped. Subbed.

  • @ashasaavoss3549
    @ashasaavoss3549 6 лет назад

    This is great! Thank you so much!

  • @parikshitpadture4122
    @parikshitpadture4122 6 лет назад +1

    Thanks for the well illustrated video on class module. Can you give a next video on how to make the object name dynamic so that the code lines need not be repeated for each object and handled within a loop.
    My class module has more than 100 properties and there are 8 objects of this class. Hence i do not want to repeat the lines for each object.

  • @vijaysahal4556
    @vijaysahal4556 5 лет назад

    superb mr john

  • @RenanWeno
    @RenanWeno 7 лет назад +7

    Easier than reading the microsoft page!!!

    • @BusinessProgrammer
      @BusinessProgrammer  7 лет назад

      I agree the tech spec pages can be cryptic or unnecessarily complicated

  • @austinhummel5439
    @austinhummel5439 5 лет назад +3

    Very intense at 1.5x speed. Music makes it seem like we're disarming a bomb in an action movie.

  • @maintalbischofsheim
    @maintalbischofsheim 5 лет назад

    Very usefull! Thank You sir.

  • @JarintipPKOI
    @JarintipPKOI 7 лет назад

    Thank you, Sir.

  • @rodrigomonney
    @rodrigomonney 8 лет назад +3

    Very Good! its hard to find good material

    • @BusinessProgrammer
      @BusinessProgrammer  8 лет назад +1

      Hi Rodrigo, Glad you liked it.

    • @blingblingsam1490
      @blingblingsam1490 7 лет назад +1

      +Sean Johnson hello sir, how do you create a class module to trigger click event for activex spreadsheet (not user form) checkboxes... ole object checkbox1, checkbox2, checkbox3 etc so I don't have to write code for each individual checkbox?

  • @rolikaseventysix
    @rolikaseventysix 5 лет назад

    I don't have a sister, wasn't able to try this code. Just joking... Thank you for the video!

  • @joaobatistaful
    @joaobatistaful 5 лет назад

    Very good

  • @vikasguldas
    @vikasguldas 6 лет назад

    cool, Thumbs up.

  • @samuelkingston4572
    @samuelkingston4572 7 лет назад

    Fine Sir!!

  • @origami_canoe1952
    @origami_canoe1952 5 лет назад

    This was great! So, as we go along creating these objects, how do we save them for later use?
    For example, a class named Users with properties like username, password, gender, age etc...

    • @wattjock2405
      @wattjock2405 3 года назад

      I believe that you can export the Class Modules... then import them into your next Project.
      Also, you can put the Class Module into your Personal Macro Workbook by dragging/dropping... then reverse that into your new Project.

  • @luisojero8059
    @luisojero8059 6 лет назад

    My bien no te entiendo pero te veo, gracis

  • @mohsinfareed1797
    @mohsinfareed1797 4 года назад +1

    Great tutorial. Very annoying background music. Is very distracting I wish you did not add background music

    • @BusinessProgrammer
      @BusinessProgrammer  4 года назад

      I wish I had left the background music out also, probably need to create another video on this topic.

  • @quinnjin2
    @quinnjin2 4 года назад

    Is this your music Sean?

    • @BusinessProgrammer
      @BusinessProgrammer  4 года назад

      It's comes with camtasia studio - screenrecorder/ video editor.
      I've stopped using music in my videos as most people find it distracting.

  • @jalipinjuanis8566
    @jalipinjuanis8566 7 лет назад

    lil wayne guitar solo in the background music

    • @BusinessProgrammer
      @BusinessProgrammer  7 лет назад

      I don't know what you mean, it's canned music licensed by Techsmith - camtasia studio.

  • @talkohavy
    @talkohavy 7 лет назад

    Question:
    Suppose I have a class and it has a local variable called locVar. How would I call and use it in a method of that class? Can I just type(for instance) "locVar=..." or do I need to use dot (meaning, something like: class.locVar) ?

    • @BusinessProgrammer
      @BusinessProgrammer  7 лет назад +1

      Hi Tal
      You need to declare the local variable as a module level variable within the class and then you can use it within all of your methods. So if you have a string local variable say Zip Code for example, then I would do something like this...
      Private mszZipCode as String ' (msz meaning module scope, string)
      mszZipCode can be used anywhere within your class but cannot be used outside it.
      Hope that helps...

    • @talkohavy
      @talkohavy 7 лет назад

      Yes, that helped very much:)
      Thank you!

  • @jitendrakashyap3023
    @jitendrakashyap3023 6 лет назад

    can anybody help me out...i m doing a programme....i want a single click to work in multi sheets. but alltime i have to go in vb programme and run that in a connected proper sheet. i want to run that program when i will be in vb of sheet 1 and program output will be in sheet 3.I hope i tried my best to make u understand my problem.plz help me bro.

    • @christianbaert607
      @christianbaert607 6 лет назад

      If you avoid to use "Feuil3.Select" anywhere in your program, it should work ... You can refer to cells in Feuil3 without selecting it. I am not sure if this what you are looking for.

  • @johndavy3820
    @johndavy3820 2 года назад

    Video was what I wanted but the music was too loud and not needed. Quite annoying

  • @jaysolanki8366
    @jaysolanki8366 4 года назад

    Can someone explain in simple words what is an instance please......

    • @BusinessProgrammer
      @BusinessProgrammer  4 года назад +1

      HI Jay
      If you look at the image on the front of my video, you'll see clsCar at the top and rally car, Race Car and Police car beneath, rally, race and police car are instances.
      People use a cookie cutter as a metaphor for classes, the cookie-cutter being the class and the cookie being the instance of the class, you can't eat the cookie cutter but you can eat the cookie. Similarly, you can't use the class directly but you can use the objects created from the class, the objects are the instances.
      With a standard module you just run the code, but with a class module you have to create an instance of it with
      dim instance as clsModuleName
      set instance = new clsModuleName
      instance.Drive
      instance.NumberOfWheels = 4
      Hope this helps

    • @jaysolanki8366
      @jaysolanki8366 4 года назад

      @@BusinessProgrammer omg thanks you replied
      Oh that was great explanation
      Thanks for sharing your precious knowledge and time 😊

    • @jaysolanki8366
      @jaysolanki8366 4 года назад

      @@BusinessProgrammer Hey sorry to disturb you again
      we use
      Dim Instance as ClassModule
      Set Instance = New ClassModule
      is this method applied only when we define a class?
      Because I have seen people using this method for the class modules which are already defined by excel
      Thanks

    • @BusinessProgrammer
      @BusinessProgrammer  4 года назад

      This method is used to create an instance of an object, Excel and other Microsoft vba programs also have built in classes so you instantiate them in the same way as class modules.
      For example the collection class is built into vba therefore...
      dim objC as collection
      set objC = New Collection
      objC.add "Some Item"
      Hope that helps

    • @jaysolanki8366
      @jaysolanki8366 4 года назад

      @@BusinessProgrammer oh okay got it thank you 😊

  • @danieleugen2010
    @danieleugen2010 4 года назад

    Thanks, but the music made it impossible to concentrate and it overpowered your voice. I've never understood why people add music to these kinds of instructional videos. If the viewers want music, they can play it on their own devices.

    • @BusinessProgrammer
      @BusinessProgrammer  4 года назад

      I stopped adding music a long time ago, problem is I can't remove it from the older videos

  • @jaro-ch
    @jaro-ch 5 лет назад

    Music is annoying

  • @michaellarsen1987
    @michaellarsen1987 Год назад

    I really would have like so see your video but the annoying and distracting music made me leave....