+ Reply to Thread
Results 1 to 18 of 18

Acquiring VBA knowledge

Hybrid View

Aland2929 Acquiring VBA knowledge 10-16-2012, 04:04 AM
thisisgerald Re: Acquiring VBA knowledge 10-16-2012, 04:09 AM
Bishonen Re: Acquiring VBA knowledge 10-16-2012, 05:36 AM
AB33 Re: Acquiring VBA knowledge 10-16-2012, 08:56 AM
Kyle123 Re: Acquiring VBA knowledge 10-16-2012, 09:31 AM
AB33 Re: Acquiring VBA knowledge 10-16-2012, 10:10 AM
Kyle123 Re: Acquiring VBA knowledge 10-16-2012, 10:27 AM
AB33 Re: Acquiring VBA knowledge 10-16-2012, 11:36 AM
Kyle123 Re: Acquiring VBA knowledge 10-16-2012, 11:43 AM
AB33 Re: Acquiring VBA knowledge 10-16-2012, 12:04 PM
Aland2929 Re: Acquiring VBA knowledge 10-17-2012, 01:48 AM
Kyle123 Re: Acquiring VBA knowledge 10-17-2012, 04:10 AM
arlu1201 Re: Acquiring VBA knowledge 10-17-2012, 04:51 AM
AB33 Re: Acquiring VBA knowledge 10-17-2012, 06:20 AM
JosephP Re: Acquiring VBA knowledge 10-17-2012, 06:42 AM
AB33 Re: Acquiring VBA knowledge 10-17-2012, 03:03 PM
JosephP Re: Acquiring VBA knowledge 10-17-2012, 03:30 PM
AB33 Re: Acquiring VBA knowledge 10-17-2012, 03:53 PM
  1. #1
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    858

    Acquiring VBA knowledge

    I am very keen to improve my VBA skills to an advanced level. Would buying a book like "C++ programming for Dummies" assist me in becoming more proficient in VBA? What would your advice be to take my limited VBA skills to the next level as I often need to do development that requires VBA? Are there online courses available?
    Thanks in advance

  2. #2
    Forum Contributor
    Join Date
    09-05-2012
    Location
    It's more fun in the Philippines :D
    MS-Off Ver
    Excel 2007
    Posts
    209

    Re: Acquiring VBA knowledge

    @Aland2929

    I believe you are looking for the link below:

    http://www.excelforum.com/excel-prog...materials.html
    Don't forget to mark your thread as [SOLVED].

  3. #3
    Valued Forum Contributor
    Join Date
    03-17-2012
    Location
    Warsaw, Poland
    MS-Off Ver
    2007/2010
    Posts
    555

    Re: Acquiring VBA knowledge

    Start with J. Walkenbachs "Excel 2010 Power Programming with VBA". Then move to "Professional Excel Development: The Definitive Guide to Developing Applications Using Microsoft Excel, VBA, and .NET (2nd Edition) "

    Assuming that you haven't touched C++ as of now, I'd say that it would be a rather bad idea to buy a C++ book to learn VBA. C++ has another syntax - when you get used to it, it might be hard to switch to VBA's one. Furthermore it's just a waste of time to learn C++ only to get closer to VBA. It's like learning Chinese to make it easier to learn Spanish. They're both languages - that's true. But what else do they have in common ? Why not learn Spanish from the begining?

    just my two cents
    If you think that my answer was helpful, please click on the "Add to this user's Reputation" button.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Acquiring VBA knowledge

    Personaly, I would not spent $35 for a book. Yes, books are good for reference, but IMO, it is really bad idea to learn VBA from books. Most books do not teach you the nuts and bolts of practical VBA. Books tend to focus on user forms and dialogue box which are useless if you do not understand why the code behind these fancy pictures does. I have bought over 10 books and spent lots of money. I did not make any head way until I watched you tube videos and forums. The best and cheapest (0.01£) of the all the books I bought so far is a self thought book by Harrris. It is really very old book-excel 1997 to be precise. The book is over 2000 pages and covers every topic from A-Z.

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Acquiring VBA knowledge

    It depends what your goals are, whether you want to be better at Excel VBA so you can do more stuff more easily, or really understand the language.

    There are loads of books and resources out there that discuss the former, but fewer that attack the latter. One of the most comprehensive (and a bit of a beast) I've ever come across for the latter is the VBA Developers Handbook by Gilbert and Getz, it's difficult to get your hands on a copy, but it treats VBA as a language in its own right, rather than merely a method of automating Excel.

    So it really comes down to what your goals are and what you want to do, though I'd argue that being good with Excel (Excel automation) rather than really understanding the language (which is really only a dumbed down, stripped back version of VB6) is far more useful, once you understand the Excel object model, you're away really.

    If you're just wanting to learn a programming language, there are far better choices out there than Excel VBA

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Acquiring VBA knowledge

    Kyle! Thanks for your input in to this thread.

    I had a quick glance on Amazone customers' review on "VBA Developers Handbook by Gilbert and Getz". Your description of the book and its target market comments seem to agree with your view. The book priced at just under £900. Oops!
    The most expensive and worst book I have ever bought( With out naming the Autor) was £45. I think this is my ceiling for a book. Nowdays, you can learn any stuff from the "University of Google"

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Acquiring VBA knowledge

    haha I think that's probably out of print, I got it here https://play.google.com/store/books/...d=46toCUvklIQC

    Quote Originally Posted by AB33
    Nowdays, you can learn any stuff from the "University of Google"
    I'm inclined to agree on most things, but that book is something else it's certainly not for the faint hearted, there's a whole chapter on rolling your own dynamic custom data structures and they hit Classes and custom Objects as early as chapter 5 of 15, the only problem with buying an electronic copy is that you don't get the code to go along with it.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Acquiring VBA knowledge

    Kyle! I am still in te faint hearted space. I have searched the net on Dictionary and collections objects and found some useful links and articles. I do not mind buying a book on dic and create object stuff. I have yet to see any VBA books which covers these topics in details, some of the books merely touch them.

  9. #9
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Acquiring VBA knowledge

    The book actually takes you through collections and how to create custom collections. I suspect that they aren't discussed in detail in many books since they aren't particularly complex & a dictionary is just a better collection.

    A dictionary is actually a better name than a collection since you look up items by a name/key

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Acquiring VBA knowledge

    Kyle!
    "I suspect that they aren't discussed in detail in many books since they aren't particularly complex & a dictionary is just a better collection".
    Funny you said it!
    I hope if I were in your shoes. Yes, it might be easy to understand the basics of key and item, but it is a hell a lot difficult to use dic in real world. I am probably not the only who feels this way. If a dic were easy, I suspect I would have seen lots of people using them in their code. IMO,dic combined with arrays has really a powerful stuff like in a duplicate data situation.

  11. #11
    Forum Contributor
    Join Date
    06-11-2009
    Location
    Cape Town
    MS-Off Ver
    Microsoft 365
    Posts
    858

    Re: Acquiring VBA knowledge

    Thanks to all for the reponses. I think the best route is a combination of books and practical application. Working on a specific project is time-consuming but a very rewarding learning experience and probably the best way to learn.

  12. #12
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: Acquiring VBA knowledge

    @AB33 apologies if I sounded condescending, that wasn't my intention. I merely trying to set the complexity of collections in the grand scheme of things.

    The easiest way to think about collections is as an untyped associative array. Untyped meaning that they aren't fussy about what you stick in them whereas an array of integers would only allow integers for example and associative as in they have strings that you can refer to the elements by.

    So whereas a normal array is just a list of data that you can access by knowing its index (position) a collection as well as allowing you to access its elements by index also allow you to give them a reference to call them by, for example:

    Array of Doubles:
    	1.00
    	2.00
    	3.00
    	4.00
    
    Access of array syntax:	 array(x)
    Accessing 2nd element:	 array(1)
    
    Collection:
    	"Kyle" 	1.00
    	"AB33" 	2.00
    	"James" 3.00
    	"john" 	4.00
    
    Access of collection syntax: Collection(x) - or - Collection("key") 
    Accessing 2nd element: Collection(2) - or - Collection("AB33")

    The caveat is that all keys must be unique for obvious reasons, collections are useful in that you can add to them, remove from them by key or index and insert into them between 2 items. You don't need to know how many elements you will put in it in advance like you would with an array, you can just add more elements. This does come at a cost though, collections are slower than arrays more noticeably as the collections get larger since each time you add something to a collection, the whole collection gets re-indexed behind the scenes.

    Collections are limited in that although you can reference an element by its key, you cannot return the keys from the collection. So you can't check to see if an element exists.

    Dictionaries function in the same way as collections, but allow you to return the keys therefore to check if an element exists by its key. Dictionaries also allow you to remove all its elements.

    So why aren't they used more? Well it's horses for courses, collection objects are slower than arrays, they're also less useful in most scenarios. For example, you can't assign a range of values to a collection object like you can a variant array:
    dim var
    var = sheets(1).currentregion.value
    You have to loop through the whole range/array and add items individually and you can't use Excel functions on them e.g
    application.sum(array)
    , you can't use functions like join and filter etc on a collection either

    You do often see them used for getting unique elements from a range, this works like this:
    Dim oCell As Range
    Dim coll As Collection: Set coll = New Collection
    
    For Each oCell In Sheets(1).Range("a1:b10")
        On Error Resume Next
        coll.Add oCell.Value, oCell.Value
    Next oCell
    Since keys have to be unique, the collection.add will fail for duplicate values and the element will not be added (that's why On Error resume Next is needed) - remember you can't check to see if a key exists in a collection.

    The same thing but for a Dictionary:
    Dim oCell As Range
    Dim dic As Dictionary: Set dic = New Dictionary
    
    For Each oCell In Sheets(1).Range("a1:b10")
        If Not dic.Exists(oCell.Value) Then
            dic.Add oCell.Value, oCell.Value
        End If
    Next oCell
    Of course with both the above, if we wanted to write the data back to the sheet we'd have to loop through the full object - you can't assign an array to a collection or vice versa

    This is more elegant since we can check if a key exists and if so, not add it again (no reliance on errors). So as I mentioned earlier, dictionaries are just richer collections. Collection objects are not hugely complicated, but the way they're used can be.

    Here's a coincidence, a collection question I answered this morning: http://www.excelforum.com/excel-prog...rom-range.html

    Hope this helps

  13. #13
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,167

    Re: Acquiring VBA knowledge

    Wow Kyle, this was very informative. I am someone who runs away from arrays, collections & dic...so this may help me come a lil closer to it.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  14. #14
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Acquiring VBA knowledge

    Kyle! Do not be silly!

    No you are not condescending. You are actually one of the first person who opened my eyes on dic. I asked this question on this thread and you went in to a greater length to explain to me. I have lots of respect for you. I am here to learn and do not feel in any way condescending if people try to explain to me in what ever they feel. I value their time and skills.

    In the next post, I will show you an example how I find it difficult to understand some lines of codes and you may shade light on them to me. You never know if I understand these two lines, it may turn out to be a break through on a dic and you would be my bravo.
    You see you have already converted Arlu in the world of Dic and collection.

  15. #15
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Acquiring VBA knowledge

    the reason dictionaries are not discussed much in excel vba books is probably because they aren't part of vba (unlike collections) or the excel object model. it would be far fetched to expect an excel vba book to cover every library you might conceivably reference! :-)
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  16. #16
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Acquiring VBA knowledge

    Jay! Okay, I see your point. you guys are more capable and experienced than I am. I am not not only new to VBA but also new to the world of "Programming". Therefore, my exposure to the world of VBA is very limited. I have read few popular books on VBA.Yes, I have learned some basics, but it is completly different ball of game when it comes to practical coding. In my opinion, most books do not deal with the real world of excel. They tend to focus on forms, msg box and dialague boxes. Yes, one needs to understand how these forms work, but it is pointless if you do not understand the code written behind them. I think forums are more pratical way of learnings as people are exposed to the real world issues. Learning by practice is the best and efficient way of reducing the learning curve. Everyday, I learn new stuff on this forum- thanks to the likes of you, Kely and others.
    I did not know, or seen dic object until I joined this forum. Despite only very few people use them on their code, I can see the power behind the dic object, hence I am keen to learn, but there are not many materials available on the net. I do not know any books which specifically deals with dic either. So one way going forward is to understand the dic object from codes written by other people.
    Kyle, Thanks again for your insight in the world of dic and arrays!

    I will read up and do some traning on dic and hopefully to come back with questions.

    Thanks all for your inputs!
    Last edited by AB33; 10-17-2012 at 03:55 PM.

  17. #17
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Acquiring VBA knowledge

    check out any good scripting site such as the microsoft scripting guys or 4 guys from rolla.

    I don't know what books you have been reading but I have never seen one that focuses on forms message boxes and dialog boxes. I do have a copy of the vba developers handbook I can sell you for only £850 if you wish? ;-)

  18. #18
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Acquiring VBA knowledge

    Jay!
    Thanks again!
    You may be right I might have been reading not very good books. Since I easily give up reading if I do not understand any topic or subject, I tend to buy second hand books from Amazon. One of the first and best book i bought was written in 80's for excel 97, by Harris. It was very old book but really good. It only costed me £0.01. "If you pay a peanuts, you get a monkey" saying may be true. No wonder why I am not learning fast!

    As Kyle said on his post, a book which costs over £900 is not for the fainted heart.I may be one day in the near future will buy your book. For now, I will stick with my own lower league status and hopefully to move up the ladder slowly.
    Last edited by AB33; 10-17-2012 at 04:00 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1