Find Interview Questions for Top Companies
Ques:- I would like to do the following. If cell A1 contains “Hello” and if the focus is on A1 and if the Enter key is pressed, then the focus should go to B2 and a MsgBox should appear. I think this can be done with key events, something like OnKeyDown, but how
Asked In :- western power,
Right Answer:
You can achieve this using the `Worksheet_SelectionChange` and `Application.OnKey` methods in VBA. Here’s a sample code:

1. Open the VBA editor (ALT + F11).
2. In the relevant worksheet, add the following code:

```vba
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.OnKey "~", "GoToB2"
Else
Application.OnKey "~"
End If
End Sub

Sub GoToB2()
MsgBox "You pressed Enter!"
Range("B2").Select
End Sub
```

This code checks if the selected cell is A1 and assigns the Enter key to the `GoToB2` subroutine, which shows the message box and moves the focus to B2.
Ques:- What is the difference between Msgbox Statement and MsgboxQ function?
Asked In :- natixis,
Right Answer:
The MsgBox statement is a built-in function in VBA that displays a message box to the user with options for buttons and icons, while MsgBoxQ is not a standard VBA function and may refer to a custom implementation or a specific context not widely recognized in standard VBA documentation.
Ques:- Name the four different cursor and locking types in ADO and describe them briefly
Right Answer:
The four different cursor and locking types in ADO are:

1. **Forward-Only Cursor**: This cursor allows moving forward through the recordset only. It is efficient for reading data sequentially.

2. **Static Cursor**: This cursor provides a static copy of the data. Changes made by other users are not visible, and it allows for random access to records.

3. **Dynamic Cursor**: This cursor reflects all changes made to the data by other users in real-time. It allows for both forward and backward navigation.

4. **Keyset Cursor**: This cursor allows you to see changes made by other users to the data, but the set of records is fixed based on the keys of the records. It allows for random access.
Ques:- What are the ADO objects? Explain them.
Asked In :- natixis,
Right Answer:
ADO (ActiveX Data Objects) consists of several key objects:

1. **Connection**: Used to establish a connection to a data source (like a database).
2. **Command**: Used to execute a command against a data source, such as SQL queries.
3. **Recordset**: Used to hold a set of records returned from a database query.
4. **Parameter**: Represents a parameter to a Command object, allowing for dynamic queries.
5. **Field**: Represents a single column in a Recordset.
6. **Error**: Provides information about errors that occur during ADO operations.
Ques:- Type Library and what is its purpose?
Right Answer:
A Type Library is a binary file that contains definitions of interfaces, classes, and other types used in COM (Component Object Model) programming. Its purpose is to provide information about the objects and their methods, properties, and events, allowing developers to use these components in their applications, often facilitating interoperability between different programming languages.
Ques:- VB and Object Oriented Programming
Right Answer:
VB (Visual Basic) supports Object-Oriented Programming (OOP) principles such as encapsulation, inheritance, and polymorphism through the use of classes and objects. In VB, you can define classes to create objects, encapsulate data and methods, and use inheritance to create new classes based on existing ones.
Ques:- I would like to do the following. If cell A1 contains “Hello” and if the focus is on A1 and if the Enter key is pressed, then the focus should go to B2 and a MsgBox should appear. I think this can be done with key events, something like OnKeyDown, but how do I tell it I want the event only be triggered by the Enter key?
Asked In :- temasek, equity methods,
Right Answer:
You can achieve this by using the `Worksheet_Change` and `Application.OnKey` methods in VBA. Here’s a simple implementation:

1. Open the VBA editor (Alt + F11).
2. In the relevant worksheet module (e.g., Sheet1), add the following code:

```vba
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.OnKey "~", "EnterKeyPressed"
Else
Application.OnKey "~"
End If
End Sub

Sub EnterKeyPressed()
If Range("A1").Value = "Hello" Then
Range("B2").Select
MsgBox "You pressed Enter on A1!"
End If
End Sub
```

This code sets up an event that listens for the Enter key when A1 is selected, and if A1 contains "Hello", it moves the focus to B2 and shows a message box.
Ques:- What is differece b/w Module and class Modules in vb6?thanks
Asked In :- praxis business school,
Right Answer:
In VB6, a Module is a container for procedures and functions that can be accessed globally throughout the project, while a Class Module is used to define a new object type with its own properties, methods, and events, allowing for encapsulation and object-oriented programming.
Ques:- How to register a component?
Right Answer:
To register a component in VBA, you can use the `Regsvr32` command in the Command Prompt. For example, type `Regsvr32 "C:PathToYourComponent.dll"` and press Enter. Make sure to run the Command Prompt as an administrator.
Ques:- Advantage of ActiveX Dll over Active Exe
Right Answer:
ActiveX DLLs are faster and more efficient than ActiveX EXEs because they run in the same process as the client application, reducing overhead and allowing for better performance. Additionally, ActiveX DLLs can be reused by multiple applications simultaneously, while ActiveX EXEs run in separate processes, which can lead to higher resource consumption.
Ques:- Which controls have refresh method?
Asked In :-
Right Answer:
The controls that have a Refresh method include the Form, Report, and certain ActiveX controls like the Image control in VBA.
Ques:- What does Option Explicit refer to?
Asked In :- natixis, ecmwf, equity methods,
Right Answer:
Option Explicit is a statement in VBA that requires all variables to be declared before they are used, helping to prevent errors related to undeclared or misspelled variables.
Ques:- Benefit of wrapping database calls into MTS transactions
Asked In :-
Right Answer:
Wrapping database calls into MTS (Microsoft Transaction Server) transactions ensures data integrity and consistency by allowing multiple operations to be treated as a single unit of work. If any operation fails, the entire transaction can be rolled back, preventing partial updates and maintaining the database's state.
Ques:- What are the different compatibility types when we create a COM component?
Right Answer:
The different compatibility types when creating a COM component are:

1. **Binary Compatibility** - Ensures that the component can be used with existing clients without recompilation.
2. **Source Compatibility** - Allows the component to be modified without breaking existing client code, but may require recompilation.
3. **Version Compatibility** - Manages changes in the component's interface while maintaining compatibility with older versions.
Ques:- 3 main differences between flexgrid control and dbgrid control
Asked In :-
Right Answer:
1. **Data Binding**: DBGrid is specifically designed for displaying and editing data from a database, while FlexGrid is more flexible and can display data from various sources, not limited to databases.

2. **Customization**: FlexGrid allows for more customization in terms of layout and appearance, whereas DBGrid has a more fixed structure tailored for database records.

3. **Functionality**: DBGrid provides built-in features for data navigation and editing, while FlexGrid requires additional coding to implement similar functionalities.
Ques:- Which property of textbox cannot be changed atruntime and what?s the maximum size of a textbox?
Asked In :-
Right Answer:
The property of a textbox that cannot be changed at runtime is the "Name" property. The maximum size of a textbox is 32,767 characters.
Ques:- For C sharp,At the time of software is implemented at clientsite, is it required that client machine have Csharp(Microsoft Visual Basic) setup?
Asked In :- temasek,
Right Answer:
No, the client machine does not need to have C# (Microsoft Visual Basic) setup. The application can be compiled into an executable that runs independently on the client machine.


VBA, which stands for Visual Basic for Applications, is an event-driven programming language developed by Microsoft. It is integrated into and used primarily with Microsoft Office applications, including Excel, Word, Access, and PowerPoint. The primary purpose of VBA is to enable users to automate repetitive tasks, customize application features, and extend the functionality of the standard software. It provides a powerful tool for users—from novice to expert—to make their work more efficient without needing to learn a separate, complex programming language.

The core of VBA’s functionality lies in its ability to create macros. A macro is a sequence of instructions that a user can record and then run to perform a series of actions with a single command. For example, in Microsoft Excel, a user can record a macro to format a spreadsheet, sort data, and create a pivot table. Once recorded, this macro can be run with a single click, saving a significant amount of time on a repetitive task. Beyond simple recorded macros, a user can write complex VBA code to create highly customized solutions.

Key uses and benefits of VBA include:

  • Automation of Tasks: The most common use of VBA is to automate tasks that are performed repeatedly. This could include generating reports, formatting documents, sending out standardized emails, or updating data across multiple spreadsheets. This automation significantly reduces manual effort, saves time, and minimizes human error.
  • Customization and Enhanced Functionality: VBA allows users to add custom buttons, dialog boxes, and functions to their Office applications. For instance, a developer could create a custom user form in Excel to input data in a user-friendly way, or a button in Word that automatically formats a document according to a company’s style guide.
  • Data Manipulation: VBA is particularly powerful in Excel for manipulating large datasets. It can be used to perform complex calculations, filter and analyze data, and import or export data from other sources.
  • Integration Between Applications: VBA can be used to make different Office applications work together. For example, a user could write a VBA script in Excel to pull data from a database in Access and then generate a report in Word, seamlessly integrating the functionality of all three programs.

While the rise of newer technologies has reduced VBA’s prominence in some areas, it remains a highly relevant and indispensable tool for professionals who rely on the Microsoft Office suite for their daily work. Its accessibility and its direct integration into widely used software make it an invaluable skill for anyone looking to optimize their workflow and streamline business processes.

AmbitionBox Logo

What makes Takluu valuable for interview preparation?

1 Lakh+
Companies
6 Lakh+
Interview Questions
50K+
Job Profiles
20K+
Users