Top Interview Questions for Excel VBA 2019
Q1. Explain what's VBA or Visual Basic for Applications?
Ans: VBA stands for Visual Basic for Applications; it's far an event-pushed programming language advanced by Microsoft. It is predominantly used with Microsoft office applications like MS-word, MS-Access, and MS-Excel.
<click here for Excel VBA>
Q2. Mention in which you can write your VBA software for Macro?
Ans: The module is the place in which you can write VBA application for Macro, to insert a Module navigate to Insert -> Module.
Q3. Mention what are the comments fashion utilized in VBA?
Ans: Comments are used to report this system log`ic and the consumer statistics with which other programmers can paintings seamlessly on the same code within the destiny. There are specifically two strategies in VBA to symbolize remarks.
Any statement that starts offevolved with a unmarried quote is dealt with as a remark.
Or you may use statement REM in place of single citation mark (‘)
Q4. In VBA how we can declare variable and constant?
Ans: In VBA, variable may be declared with the keyword “DIM” whilst regular is said with key-word “Const.”
Q5. Mention how can you remark and uncomment blocks of code within the office VBA editor?
Ans: In workplace VBA editor, you may remark and uncomment blocks of code through following steps:
In the VBA editor visit View->Toolbars -> Customise… OR proper click on at the toolbar and pick Customise
Select the edit menu at the left, under the commands tab
When you scroll down you may see icons, “Comment Block” and “Uncomment ”
When you drag and drop those onto your toolbar, you may have clean access to highlight a block of code and do action on it.
Q6. Explain what's ADO, ODBC, and OLEDB?
Ans: ADO: ActiveX Data Objects or ADO is a common facts access framework that encompasses the capability of DAO.
ODBC: Open Database Connectivity or ODBC is a generation that allows a database purchaser software to connect to an external database.
OLEDB: It is a low-level programming interface designed to get admission to a huge variety of facts access object linking and embedding (OLE)
Q7. Explain about feature recommendations in VBA?
Ans: The VBA (Visual Basic Information) have bendy programs, but there is a limitation to a feature pointer in VBA. Windows API has inadequate help for feature recommendations because it has the potential to apply the feature but now not the useful guide to call again the characteristic. It has inbuilt aid for the call however now not for a callback.
Q8. Explain how “reference counting” in VBA is performed?
Ans: In VBA, quickly a variable goes out of scope, the reference counter at the reference item is decremented. When you assign the object reference to some other variable, the reference counter is incremented. While when your reference count number reaches to 0 it terminates the occasion.
Q9. How can you lower the reference counter explicitly?
Ans: To decrease the reference counter explicitly, you need to set a variable to “Nothing”.
Q10. Explain what's COM (Component Object Model) items in VBA?
Ans: COM gadgets are commonly .Dll files, and are compiled executable applications.
Q11. Explain how can you dial a phone wide variety via VBA?
Ans: In order to dial a cellphone quantity through VBA, you want to observe the following steps:
Shell command in VBA can be used to start the dialer present in Windows O.S.
To hook up with your modem, the smartphone quantity may be used.
With the help of ship keys and shell command, you could dial on your consumer.
Sendkey dictate the home windows to dial according to the keystrokes of the application at the same time as Shell turns on the Windows software.
A macro may be used to initiate the cardboard document application which triggers the automobile-dialer function.
Q12. Explain what is the meaning of “Option Explicit”? Where it need to be used?
Ans: “Option Explicit” makes the announcement of variables obligatory. Line specific characteristic makes the compiler to decide all of the variables that aren't declared by means of the dim statement. This command diminishes the hassle of type errors notably. It is utilized in VBA as it deals with records-rich utility in which kind errors are common. Before starting any, sub-processes it may be used internal a module.
Q13. Explain how are you going to pass arguments to VBA capabilities?
Ans: When arguments are handed to VBA functions, they may be handed in approaches:
ByVal: When a controversy is surpassed by means of Value, then it method that best cost is passed to the process, and any modifications which are made to the argument within the system might be lost while the process is exited.
ByRef: When the argument is passed with the aid of reference than the real address of the argument is passed to the manner. Any adjustments which can be made to the argument inside the procedure could be recalled while the process is exited.
Q14. Mention the approach this is known as from the ObjectContext item to inform MTS that the transaction changed into unsuccessful or a hit?
Ans: Set approximately and set complete technique are called from the ObjectContext item to inform MTS that the transaction became unsuccessful or unsuccessful.
Q15. What is the code to find a ultimate used Row in a column or last used Column of a row?
Ans: To find the remaining row in a column, the command used is End(xlUp) and to locate remaining column in a row, the command used is End(xlToLeft).
Q16. Mention the difference between the Subroutines and Functions in VBA?
Ans: The distinction among the Subroutines and Functions is that:
Subroutines by no means go back a price, however capabilities do go back values.
Subroutines ought to change the values of the real arguments whilst a function couldn't trade the value of actual arguments.
Q17. Explain what's the distinction among CurrentRegion properties and UsedRange?
Ans:
CurrentRegion: The present day region is a variety bounded by using any mixture of clean columns and rows.
UsedRange: This belongings is used to select the range of used cells on a worksheet. It returns a Range item that represents the used variety on the particular worksheet.
Q18. Explain a way to debug a VBA code?
Ans: To debug a VBA code, comply with the steps:
Using Breakpoints (F9).
Step via step execution (F8).
Print & Immediate Window and Watch the window.
Q19. How can you prevent VBA script when it goes into the countless loop?
Ans: By urgent Cntrl+ Pause Break key you will prevent VBA script while it goes into an limitless loop.
Q20. Mention which belongings of the menu cannot be set at runtime?
Ans: At runtime Name property of the menu can't be set.
Q21. Mention whether or not VBA has a dictionary structure?
Ans: Yes, VBA does have a dictionary structure. You can set a reference to dictionary like:
Set dict = CreateObject(“Scripting.Dictionary”)
OR Dim dict as New Scripting.Dictionary.

