VBA Interview Questions and Answers
Q1. What is Visual Basic for Applications(VBA)?
Ans: VBA stands for Visual Basic for Applications; it is an occasion pushed programming language advanced with the aid of Microsoft. It is predominantly used with Microsoft office applications like MS-phrase, MS-Access, and MS-Excel.
Q2. What are Data-kinds?
Ans: Data types allows to declare Variables with unique records, this helps to VBA to realize the form of the facts and assign the reminiscence based on the DataType of the Variable.
Q3. What are Scope of Variables?
Ans: We can define variable in distinct degrees:
Local Level: Variables which might be defined with DIM declaration in a procedure or features
Module Level: Which are defined with DIM assertion on top of a module, can be accessed in complete module
Global Level: Which are defined Public declaration at top of any module, can be accessed in whole challenge.
Q4. What is the distinction between Msgbox Statement and MsgboxQ feature?
Ans: MsgBox is a built in VB function which displays a Message Box and MsgBoxQ is a feature defined by way of the user.
Q5. Where you could write your VBA application for Macro?
Ans: vModule is the place in which you can write VBA application for Macro, to insert a Module navigate to Insert -> Module
Q6. What are the 4 unique cursor and locking sorts in ADO and describe them in brief?
Ans: Coursor sorts:
Forwardonly
Static
Keyset
Dyanmic
Lock types :
lockpessimistic
lockoptimistic
lockbatchoptimistic
Lockreadonly
Q7. How “reference counting” in VBA is finished?
Ans: In VBA, quickly a variable goes out of scope, the reference counter at the reference object is decremented. When you assign the item connection with every other variable, the reference counter is incremented. While whilst your reference count number reaches to zero it terminates the event.
Q8. Which controls have refresh method, clear method?
Datagrid,listbox,combobox,label,button have refresh methodand textbox has clear methodalmost all controls have refresh method
Q9. Which controls can not be placed in MDI?
Ans: The Controls which do no longer have Align property can not be placed on MDI Form.
E.G., Picturebox best has Align property in Standard Components of VB other controls dont have align assets an for this reason can't be drawn on MDI Form.
Timer manipulate can also be positioned on MDI form.
Q10. How we are able to claim variable and regular in VBA?
Ans: In VBA, variable may be declared with the key-word “DIM” whilst regular is declared with keyword “Const.”
Q11. What is insert module and Goal Seek features found in VBA?
Ans: The leader use of VBA is to make use of its unique function which allows in repeated actions. Goal are seeking feature allows to reduce manual access of the code every and every time. This solves the problem of repeated feature entry through automating functions and movements. Sub exercises are inserted into the using the VBA editor and command insert module.
Q12. How to format expressions via using VBA?
Ans: Format capabilities may be used to layout some of the expressions such as currency, time, date, chances and numbers. These capabilities are plenty easier to use in VBA. User defined date, numeric and string codecs are found in the various applications.
Q13. Explain what's ADO, ODBC and OLEDB?
Ans:
ADO: ActiveX Data Objects or ADO is a conventional statistics get right of entry to framework that encompasses the functionality of DAO
ODBC: Open Database Connectivity or ODBC is a technology that permits a database patron utility connect to an external database
OLEDB: It is a low-degree programming interface designed to get admission to a huge form of information access object linking and embedding (OLE)
Q14. Mention what are the feedback style used in VBA?
Ans: Comments are used to record the program common sense and the user statistics with which different programmers can work seamlessly at the same code in destiny. There are mainly techniques in VBA to represent remarks.
Any announcement that begins with a unmarried quote is handled as remark
Or you could use assertion REM in preference to unmarried citation mark (‘)
Q15 . Explain how are you going to pass arguments to VBA capabilities?
Ans: When arguments are exceeded to VBA capabilities, they may be passed in approaches
ByVal: When argument is passed by means of Value, then it approach that only cost is handed to the manner, and any adjustments which might be made to the argument within the process might be lost when the procedure is exited
ByRef: When the argument is exceeded via reference than the real cope with of the argument is surpassed to the manner. Any adjustments which can be made to the argument within the method might be recalled whilst the procedure is exited
Q16. Explain approximately feature pointers in VBA?
Ans: The VBA (Visual Basic Information) have flexible packages, but there may be a hindrance to a feature pointer in VBA. Windows API has inadequate assist for function hints as it has the ability to use the characteristic but now not the functional support to call returned the characteristic. It has built in assist for the decision but now not for a callback.
Q17. What does Option Explicit discuss with?
Ans: Option Explicit makes the declaration of Variables Mandatory
Q18. What is the meaning of “Option Explicit”? Where it have to be used?
Ans: “Option Explicit” makes the assertion of variables mandatory. Line specific characteristic makes the compiler to decide all the variables that are not declared by means of the dim declaration. This command diminishes the trouble of kind errors substantially. It is used in VBA as it offers with data wealthy software in which kind mistakes are common. Before starting any, sub-techniques it could be used inside a module.
HubSpot Video
Q19 . How can you decrease the reference counter explicitly?
Ans: To lower the reference counter explicitly, you need to set a variable to “Nothing”.
Q20. What is line option explicit?
Ans: Line express characteristic makes the compiler to become aware of all the variables which aren't detailed by way of the dim statement. This command extensively reduces the trouble of type mistakes. This is used substantially because VBA offers with information wealthy packages in which type mistakes are common.
Q21. Explain what is COM (Component Object Model) gadgets in VBA?
Ans: COM items are usually .Dll documents, and are compiled executable programs.
Q22. Explain the distinction between visible basic, VB script and visual fundamental applications?
Ans: Visual fundamental is useful in case you are planning to develop your packages from scratch. This language facilitates you in growing Active x controls, exe files, and so forth.
Visual script is a powerful tool, thru which you could create small scale applications on net pages, automation packages, and so on. Integrated development surroundings isn't always present for VB script.
Visual fundamental programs are very useful in automating your present software. VB software is useful for developing already current programs.
Q23. Which Property is used to compress a picture in photograph manage?
Ans: Stretch
Q24. Benefit of wrapping database calls into MTS transactions?
Ans: Benefit of wrapping database calls into MTS transa...
If database calls are made within the context of a transaction, aborting the transaction will undo and changes that occur within that transaction. This removes the opportunity of stranded or partial records.
Q25. What do ByVal and ByRef suggest and that is the default?
Ans: If you pass an argument with the aid of reference while calling a manner, the manner get admission to to the actual variable in memory. As a result, the variable's value can be modified by using the method.
If you bypass an argument via value whilst calling a technique, the variable's cost may be modified with in the process simplest outside the real price of the variable is retained.
Passing by reference is the default in VBA. If you do now not explicitly specify to pass an argurment via value, VBA will skip it via reference.
Argument Passing ByVal
Describes passing arguments via price, which means that the procedure can't adjust the variable itself.
Argument Passing ByRef
Describes passing arguments via reference, which means that the technique can adjust the variable itself.
Q26. Mention the approach that are called from the ObjectContext item to notify MTS that the transaction was unsuccessful or successful?
Ans: Setabort and setcomplete technique are referred to as from the ObjectContext object to notify MTS that the transaction became unsuccessful or unsuccessful
Q27. Explain Which assets of textbox can't be modified at runtime and what?S the most size of a textbox?
Ans: MultiLine Property
No limits
Q28. What is the code to find a closing used Row in a column or closing used Column of a row?
Ans: To discover the ultimate row in a column, the command used is End(xlUp) and to find remaining column in a row, the command used is End(xlToLeft).
Q29. How to apply records validation function in VBA?
Ans: Data validation is an critical concept in VBA. Application method and a custom conversation container can be used to correct enter mistakes. You can assign an utility technique to the frame of a dialog container. Error message or custom dialog box may be highlighted with the first area with mistakes.
Q30. Explain how will you dial a smartphone number thru VBA?
Ans: In order to dial a telephone variety thru VBA, you need to follow the subsequent steps
Shell command in VBA may be used to start the dialer present in Windows O.S
To hook up with your modem, cellphone number can be used
With the help of send keys and shell command, you could dial on your consumer
Sendkey dictate the windows to dial in line with the keystrokes of the application even as Shell turns on the Windows software
A macro can be used to initiate the card file software which triggers the car dialer feature
Q31. Explain Type Library and what is its reason?
Ans: Type libraries are files that explicitly describe some or all of the contents of components. This includes data about the techniques, houses, constants, and different members uncovered with the aid of the factor. Development gear including Visual Basic employ the information contained in the type library to help you, as a developer, get right of entry to and use the factor. In addition, kind libraries provide a handy way to encompass a simple stage of descriptive documentation for element individuals.
Q32. Mention the difference between the Subroutines and Functions in VBA?
Ans: The distinction between the Subroutines and Functions is that
Subroutines in no way return a cost, however functions does go back values
Subroutines may want to alternate the values of the actual arguments whilst a characteristic could not change the cost of actual arguments

