• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to write Shorter (Optimised) Code to by pass Long Parent-Child Accessing ?

Dear All,

How Some codes work like a charm ?? though. (its seems) its not written as per Guideline of "Excel VBA" Which always force to Recall Parent to child...for accessing things ..in long sentences & look like we Re-Generate "The Ten Commandments...".

for just example. Code From SirJB7...(Please refer their codes)..

that code look very short .. very shortly coded , optimized & accurately work....& work without fail... without any error....its not in General VBA terms ...may be we can cheat VBA through shorthand codding ..& can bypass .to force...Parent to child...how to learn this technique? What are the hidden factors in that code...that work like a charm without error??

Regards,
Chirag Raval
 
Understanding of data structure is key. Then it's simply matter of honoring object model and qualifying reference context where needed (i.e. understanding context in which the code refers to each object and how it's related).

Other means of shortening code...
Learning various methods such as Scripting.Dictionary, For Each Loop, While Wend, etc.

However, do note that shorter code does not necessarily mean optimized code nor is it always best. Even if the code is longer, if it's easier to understand and edit variables, then in my opinion it's better than using shorter code (especially when you consider succession planning).
 

Dear Chirag,

as here it is the Excel worksheet formulas forum, thanks next time
to create thread about code in appropriate VBA Macros forum …
 
Hi ,

Excel , and all software , work according to their rules.

Every programming language has its syntax and its rules.

Good programming requires an understanding of these , and then a grasp of how to use these basic building blocks to build what are called algorithms.

Just as putting one brick on top of another cannot make me a mason , so also , putting together all the statements correctly cannot make me a good programmer , though nowadays programming software i.e. software which can write code , is coming pretty close.

What is required is an understanding of the techniques which can solve problems ; for example , if you need to sort data , Excel has its in-built Sort method , but if you were to write a sorting algorithm in any general purpose programming language , you could choose from a variety of sorting methods ; unless you are aware of these , and you are also aware of when to use which sorting method , the code you produce would do the job , but it might be quite inefficient in terms of time , memory usage.

Excel , more particularly VBA , not being a general purpose language like say C , is quite restricted in what it allows you to do. But within these constraints , you can still do a lot , especially when it comes to data processing and calculations.

The Internet has a number of valuable resources for even complete beginners ; take a look at these :

https://excelmacromastery.com/

https://analysistabs.com/excel-vba/codes-examples-macros-how-tos-most-useful-basics-advanced/

https://blogs.office.com/2009/03/12/excel-vba-performance-coding-best-practices/

Narayan
 
Dear All,

Thanks for all for focus on Secret behind the "Short But Efficient..Never Fail..Coding" ...& there are no any "Magic"...Just Logically arrangements for
Accessing things...

I prefer also to "Chihiro" that Code Should Be "Understandable & Repairable"
may be so its look long...but work perfectly...

thanks again to you all & hope find something deep from this .

Regards,
Chirag
 
Back
Top