+ Reply to Thread
Results 1 to 5 of 5

How to write your own Excel VBA code and how to use the Object Browser to obtain such code

  1. #1
    Registered User
    Join Date
    10-03-2009
    Location
    Swansea,South Wales
    MS-Off Ver
    Excel 2003
    Posts
    8

    How to write your own Excel VBA code and how to use the Object Browser to obtain such code

    I have read many VBA guides for beginners including some from your own forum.

    However I wish to write my own VBA code for any particular situation.

    I have asked for help in the past to various problems and have always been given excellent answers.

    In such cases I have used the code provided by them to good effect .

    I wish to generate my own code to simplify and improve recorded macros content or indeed generate my own code from scratch.

    None of the guides I have read tell me how to do this.

    Some guides mention the VBA Object Browser which is claimed to be very useful but I find somewhat confusing.

    They tell me how the browser is made up - Objects - Properties - Methods etc but I do not know how to use the browser to get the required code and transfer it to the code window.

    If I am missing something obvious then do I not know what it is or where it is.

    Any advice on how I may achieve my aim would be greatly appreciated.

    regards

    Flynne

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: How to write your own Excel VBA code and how to use the Object Browser to obtain such

    The object browser will not provide code as such... it simply helps you figure out what code to write. For example if you check a worksheet object, you find that it has properties such as Name, so then you know that to change the name you would say ws.Name = xxxxxx. Unfortunately it will only give you info that helps write code, not actually build that code for you.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,827

    Re: How to write your own Excel VBA code and how to use the Object Browser to obtain such

    Instead of, or in addition to the object browser, I tend to use this help file (https://msdn.microsoft.com/en-us/lib.../ff194068.aspx ) as a gateway to the help files for the different objects, methods, and properties in Excel's object model.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,434

    Re: How to write your own Excel VBA code and how to use the Object Browser to obtain such

    I think it depends on your background and if you have any programming experience. Recording a macro is a good way of getting the basic code but it is limited. It records exactly what you do, it's slow and it's inefficient. And, typically, it records one pass when you might want a loop.

    So, for example, you might record a macro that puts a formula in lots of cells in a column. You can do that in one step without selecting anything. But that's not the way the macro recorder will show you.

    I learnt by reading lots of books, dissecting code that I found or was given, and then trying to apply and adapt the code. Nowadays, if I need to find out how to do something that I have not done before, I will Google it. Usually, I find what I want and I can adapt it. Sometimes, I don't find what I want, or I find what I think I want but I can't make it work. Then I ask questions of others and hope that someone can help. More often than not, they can and do.

    With regard to the Object Browser, I rarely use it and I don't always find it intuitive. Knowing Excel, you have to work down the hierarchy ... the Excel Application works with Workbooks, which contain Worksheets, Chart Sheets, etc. A worksheet contains cells, or ranges. A cell will contain a value or a formula and can be formatted ... very simplistic view

    I still record macros to get the basic structure for code I don't often use. And I think it's one of the best ways of learning.

    Depending on your learning style, it can be good to set yourself a task and record each step as you complete the task manually. Then you can review the code and adapt it for speed, efficiency and to make it generic. I guess you're doing that to some extent so all I can say is keep at it. And maybe buy yourself a good book. I'd recommend anything by John Walkenbach.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Registered User
    Join Date
    10-03-2009
    Location
    Swansea,South Wales
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: How to write your own Excel VBA code and how to use the Object Browser to obtain such

    Thanks to all for your prompt comments.

    I half expected the answers you gave me with thanks to you all - I didn't expect it to be easy without some ground work.

    I shall take the advice to google my vba problems and learn from the suggestions - answers I receive.

    I shall also look in the help file suggested by MrShorty and the feast of suggestions at the Excel Aids site which looks quite promising.

    Regards

    Flynne

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Write Excel formulas into VBA code
    By vio.coman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-18-2015, 04:23 PM
  2. [SOLVED] Write Excel formulas in VBA code
    By vio.coman in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-16-2015, 10:56 AM
  3. Need help to write vba code in excel to do the below ASAP
    By ohadshay in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-29-2013, 05:40 PM
  4. [SOLVED] VBA code to obtain a hyperlink
    By mmota in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-09-2013, 07:06 PM
  5. [SOLVED] IF Exists or on Error Then - Skip Code- How to write code?
    By Jack7774 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-22-2013, 06:45 PM
  6. Excel object browser
    By guss in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-31-2010, 07:36 PM
  7. [SOLVED] Will pay someone to write small Excel code for me
    By [email protected] in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-26-2005, 09:06 AM

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