Latest Excel VBA Interview Questions and Answers

Read Top Excel VBA Interview Questions and Answers Experienced, Freshers for Job Interview Quiz with Solutions.

What is Excel dependency tree?

Dependency trees are excel way of minimizing the calculation by tracking what has changed since last calculation. It allows Excel to recalculate only:
* Formulae/Names that have changed.
* Formulae containing Volatile Functions
* Formulae dependent on changed or volatile formulae or cells or names.

Excel determines dependencies by looking at the cells referred to by each formula and by the argument list of each function.
Dependency trees are immediately updated whenever a formula is entered or changed.
To force the dependency trees to be rebuilt and all formulae calculation use CTRL+ALT+SHIFT+F9.

What are keyboard shortcuts and their equivalent VBA methods for Formulae calculation and building Excel dependency trees?

Shortcut Combination VBA Equivalent Meaning
F9 Application.Calculate Recalculate
Ctrl+Alt+F9 Application.CalculateFull Full Calculation
Ctrl+Alt+Shift+F9 Application.CalculateFullRebuild Rebuild Excel Dependency Tree and Full Calculation
Shift+F9 Sheets(1).Calculate calculate Worksheet

What does Range.Dirty used for ?

To add the specified cells to the list of cells requiring calculation at the next recalculation.

How do you check the Calculation state ?

Pretty simply, using the Application.CalculationState property which tells if calculation has completed ( xlDone ), is pending ( xlPending) , or is in process ( xlCalculating ).

How do you define Excel Calculation Interruption Key to stop the calculation?

Using Application.CalculationInterruptKey= XlAnyKey | XLEscKey | XlNokey.
Remember using XlNokey, calculation cannot be interrupted.

What does ‘Workbook.ForceFullCalculation’ do?

When this property is set to True, dependencies are not loaded at open, the dependency dirty chain is not updated, and every calculation of the workbook is a full calculation rather than a recalculation.

If you have a workbook that has so many complex dependencies that loading the dependencies at workbook open takes a long time or recalculation takes longer than full calculation, you can use this property to force Excel to skip loading the dependencies and always use full calculation. Also if making a change to the workbook takes a long time in manual mode because of the time taken to dirty all the dependencies of the cell being changed, then setting Workbook.ForceFullCalculation to True will eliminate the delay.
* Although this is a workbook property the effect is at Application level rather than workbook level.
* In Excel 2007 setting the property back to False once it has been set to True has no effect on the current Excel session.
* The property is saved and restored with the workbook.
* Once this property has been set to True ‘Calculate’ shows in the status bar and cannot be removed by using calculation keys such as F9.

What are excel dependency tree limits?

There are two limits to the number of dependencies that Excel versions prior to Excel 2007 can track before it must do full calculations instead of recalculations.
* The number of different areas in a sheet that may have dependencies is limited to 65,536.
* The number of cells that may depend on a single area is limited to 8K.
After the workbook has passed these limits, Excel no longer attempts to recalculate only changed cells. Instead, it recalculates all cells at each calculation.

Mention those conditions when status bar shows CALCULATE.

There are five known conditions in which the status bar will show CALCULATE:
* The Calculation Option has been set to Manual and the workbook contains uncalculated formulae. Try setting calculation to Automatic (Tools–>Options–>Calculate). Note that Excel sets the calculation mode from the first workbook opened in a session: when you open two workbooks, one saved in manual mode and one saved in automatic mode, they will both have the calculation mode of the first workbook opened.
* The Iteration Option is turned on and the workbook contains circular references. Check that turning off Iteration (Tools–>Options–>Calculation) and pressing F9 shows “Circular Reference” in the statusbar.
* You are using Excel 2000 without the SR1 update and have a user-defined function that attempts to define a name and depends on a volatile function: see MSKB Q248179
* You have hit one of Excels limits for tracking dependencies.
* You are using Excel 2007 and have set Workbook.ForceFullCalculation to True

What do you know about multi threaded calculation?

Excel 2007 can split calculation across multiple processors or cores. When Excel 2007 loads a workbook, it determines from the operating system how many processors are available and then creates a separate calculation thread for each processor. These threads can then run in parallel. The beauty of this system is that it scales extremely well with the number of processors.

Most workbooks show a significant improvement in calculation speed on a system with multiple cores. The degree of improvement depends on how many independent calculation trees the workbook contains. If you make a workbook that contains one continuous chain of formulas, it will not show any multithreaded calculation (MTC) performance gain, whereas a workbook that contains several independent chains of formulas will show gains close to the number of processors available.

How can we dial a phone number?

Shell command present in VBA can be used to start the dialer present in windows operating system. Phone number can be used to connect to your modem. With the use of shell and sendkeys you can dial to your user. Shell starts windows application and sendkeys inform the window to dial according to the keystrokes of the application. A macro can be used to start the cardfile program which activates the auto dialer feature.

What do you know about the interpretation features of VBA?

VBA is licensed to Microsoft and this compatible with and only Microsoft products. Code written is compiled by an intermediate language called P-code and this is stored in hosting applications such as Excel, Word and Access. The intermediate code is interpreted by a virtual machine. This code and intermediate language is the exclusive right of Microsoft.

Explain about insert module and Goal Seek functions present in VBA?

The chief use of VBA is to make use of its special function which helps in repeated actions. Goal seek function helps to reduce manual entry of the code each and every time. This solves the problem of repeated function entry by automating functions and actions. Sub routines are inserted into the using the VBA editor and command insert module.

State the difference between Visual Basic, VB Script and Visual Basic for Applications?

Visual basic is useful if you are planning to develop your programs from scratch.This language helps you in developing Active x controls, exe files, etc.
VB script is a powerful tool, through which you can create small scale applications on web pages, automation applications, etc. Integrated development environment is not present for VB script.
Visual Basic for Applications are very useful in automating your existing application. VB application is useful for developing already existing applications.

Write a macro to select all the non-blank cells of Activesheet?

Sub NonBlankCells()
On Error Resume Next
Union(Cells.SpecialCells(xlCellTypeFormulas, 23), Cells.SpecialCells(xlCellTypeConstants, 23)).Select
If Err.Number 0 Then
Cells.SpecialCells(xlCellTypeFormulas, 23).Select
Exit Sub
End If
If Err.Number 0 Then
Cells.SpecialCells(xlCellTypeConstants, 23).Select
Exit Sub
End If
On Error GoTo 0
End Sub

What is the difference between UsedRange and CurrentRegion properties?

i) The current region is a range bounded by any combination of blank rows and blank columns.
This property is useful for many operations that automatically expand the selection to include the entire current region, such as the AutoFormat method. This property cannot be used on a protected worksheet.
The UsedRange property is used to select the range of used cells on a worksheet. It returns a Range object that represents the used range on the specified worksheet.
ii) Every non-blank cell got its CurrentRegion and its keyboard shortcut is Ctrl+Shift+Spacebar.
iii) There can be many current regions but there is only one used range in a worksheet.


Popular posts from this blog

TOP Agile Testing Interview Questions and Answers

Latest Agile Testing Interview Questions and Answers

Most Asked ADO.NET Interview Questions and Answers