Excel VBA Introduction Part 26 - Constants and Enumerations (Const, Enum)

Поделиться
HTML-код
  • Опубликовано: 16 мар 2014
  • If you'd like to help fund Wise Owl's conversion of tea and biscuits into quality training videos you can click this link www.wiseowl.co.uk/donate?t=1 to make a donation. Thanks for watching!
    You can buy our Introduction to Excel VBA book here www.lulu.com/shop/andrew-goul...
    By Andrew Gould
    www.wiseowl.co.uk - Constants in VBA are values which don't change - there are lots of built-in examples and you can also create your own. This video teaches you how to declare and use constants in your VBA procedures. You'll also learn how to create collections of constants called Enumerations, how to reference them in your code and also how to use them as a new data type for variables and parameters of procedures.
    Visit www.wiseowl.co.uk for more online training resources in Microsoft Excel, Microsoft Access, Microsoft PowerPoint, Microsoft Word, Microsoft Project, Microsoft Publisher, Microsoft Visio, SQL Server, Reporting Services, Analysis Services, Visual Studio, ASP.NET, VB.NET, C# and more!

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

  • @houstonvanhoy7767
    @houstonvanhoy7767 3 месяца назад +1

    Andrew: This video just blows my mind! Thanks.

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

    great tutorial, When I see it. and left all videos which I followed before and follow you

  • @jmathew6988
    @jmathew6988 Год назад +1

    Excellent Tutorial! Best part is the the examples used. Gives you 200% understanding of the topic, if not more. Thank you.

  • @timusolds3537
    @timusolds3537 10 лет назад +1

    Dear WiseOwl!!!
    Thank you very much for you videos!!! Many thanks from KZ and DE!!!
    Your Videos are just awesome!!! Thanksssss!!!!!!!!!!!!!!
    A

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

    Great tutorial; very easy to understand and in-depth at a good pace for me. I coded along and replayed tons of times.. this and the Arrays tutorial has helped me broaden my beginner's skill set. Thank you!

  • @maksimaisin743
    @maksimaisin743 7 лет назад +2

    Best VBA totur ever! Thank you very much WiseOwl, and many thanks to Andrew personnaly!

  • @abdulnayazh2366
    @abdulnayazh2366 9 лет назад +4

    All your videos are awesome man thanks....

  • @SyedKollol
    @SyedKollol 10 лет назад

    This is the first time I really liked any video on these particular topics.
    Excellent work and thanks a lot.

  • @nazaserh
    @nazaserh 3 года назад +2

    Simply brilliant 👏

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

    Excellent videos. Thank you for the tutorials.

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

    Excellent videos

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

    Excellent video!!

  • @AmitSharma-po1zb
    @AmitSharma-po1zb 5 лет назад +2

    Simply Awesome... :)

  • @tomash9785
    @tomash9785 9 лет назад

    Oh yeah finally easy to follow video after tougher ones :)

  • @adambooth3858
    @adambooth3858 9 лет назад

    Great tutorial. Thanks.

  • @Gk2810_
    @Gk2810_ 8 лет назад

    very informative ... it helped me a lot ..

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

    great series

  • @danielpenteado
    @danielpenteado 9 лет назад

    You rock!! Thks!

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

    Thanks a lot.

  • @krn14242
    @krn14242 9 лет назад

    Thank you

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

    I'm loving your tutorials. They are informative and accurate. I personally think that if you reinforced your examples by including features learned in earlier models that you'd have a greater following. In every video so far you have failed to use the the [Procedure View] / [Module View] buttons in the bottom left corner of the VBE which really helps me focus on the task at hand by hiding separate modules. The following function would have done the exact job you wanted in the circle example. I am surprised you never used it:
    WorksheetFunction.Pi
    Brilliant work so far!

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

      It's great! The resource is really helping me improve my skills. It would be rgeat to have a set that demonstrates how to build an excel application using VBA so that users can see something built from scratch that has a real world function and is useful like an accounting program that does double entry T accounts. Students would be able to recode it to their needs and learn how valuable VBA is to their job. Your teaching style is brilliant.

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

    Very informative video - I can't stress it more!
    Can you please do a video on Constants, Variables and Enums while using VBA for PowerPoint? I really need to know. I am experiencing issues while using Constants for Colors in PowerPoint VBA.

    • @tanmoyd
      @tanmoyd 8 лет назад

      +WiseOwlTutorials Thanks a lot! I understand :)

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

    awesome

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

    Hi Andrew,
    I have got stuck at one point , need your help. actually I want to pass variable name through cell reference in sheet. If that variable is present in the declared list of the module then corresponding value should come into the reference cell. can we acheive it anyway? If yes ,Please guide me. It will be really helpful. Thanks in advance.

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

    I follow your every single video. Currently I am struggling with UIAutomation in VBA. Could you please create some videos on it and help me with any material if available.

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

      Hi Sunil, I don't have any experience with UI Automation so it's unlikely that we'll have any videos on that topic, sorry!

    • @IndiaDefenceWing
      @IndiaDefenceWing 3 года назад +2

      @@WiseOwlTutorials Thanks Andrew. The best part about you is you always reply. Thanks Andrew and keep up the excellent work. It encourages us as well to learn beyond limits.

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

      @@IndiaDefenceWing Thank you Sunil, I appreciate the support!

  • @DittoGlen
    @DittoGlen 9 лет назад

    In regards to Pi constant, WorksheetFunction.Pi is also available (at least Excel 2010 its there)

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

    As usually fantastic style of description
    I have only one question :
    What is the key difference between enumerations and collection !
    And many thanks in advance

    • @WiseOwlTutorials
      @WiseOwlTutorials  3 года назад +2

      Thank you Mahdjoub!
      There are many differences between enumerations and collections. You might find the video on collections useful here ruclips.net/video/8fBUUSrmsP4/видео.html
      I hope it helps!

  • @stephenhammond1745
    @stephenhammond1745 Месяц назад

    I have started using enums and classes and find they make coding easier. Wondering if it is possible to use an enumeration in a WITH statement. Eg Define an enum named Address and then say With Address....? Is this possible?

    • @WiseOwlTutorials
      @WiseOwlTutorials  Месяц назад

      Hi Stephen! Unfortunately not, an Enum is just a set of related constants. A With statement needs to work with an object. You could use a Type to do the sort of thing you need. A basic example would look like this:
      Public Type Address
      Street As String
      Town As String
      Postcode As String
      End Type
      Sub With_Address()
      Dim a As Address

      With a
      a.Street = "Some street"
      a.Town = "Some town"
      a.Postcode = "AB12 3CD"
      End With

      End Sub
      You could use an Enum to set the datatype of one of the members of the Type like so:
      Public Enum CountryEnum
      Australia = 1
      UnitedKingdom = 2
      UnitedStates = 3
      End Enum
      Public Type Address
      Street As String
      Town As String
      Postcode As String
      Country As CountryEnum
      End Type
      Sub With_Address()
      Dim a As Address

      With a
      a.Street = "Some street"
      a.Town = "Some town"
      a.Postcode = "AB12 3CD"
      a.Country = UnitedKingdom
      End With

      End Sub
      I hope it helps!

    • @stephenhammond1745
      @stephenhammond1745 Месяц назад +1

      @@WiseOwlTutorials Ok. I had read somewhere that enums were technically considered objects but maybe that's not true or they just can't be used like other objects. I've just started looking into Types....still fairly new at this (68, retired, and using VBA as a way to keep my brain engaged). Thanks a lot for taking the time to reply. Your feedback/suggestions are very helpful.

    • @WiseOwlTutorials
      @WiseOwlTutorials  Месяц назад

      @@stephenhammond1745 It's super impressive that you're in to class modules and types already - it took me ages to wrap my head around those when I was getting started!

    • @stephenhammond1745
      @stephenhammond1745 Месяц назад +1

      @@WiseOwlTutorials I took me a while to understand that these were aids to coding rather than ways of gathering user input when the code was running. Once I realized that, using them was fairly easy. Now it's more a matter of deciding which to use in any particular case.

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

    Why combine one concept people are trying to learn with something more complex like the area of a circle? Why not pick an example everyone understands intuitively, so they're not trying to learn the concept while dealing with additional unnecessary complexity? Why not use something like a tax rate or hours in a day, vs. Pi and area of a circle? Great tutorial, but keep it as simple as possible.