Excel Interview Questions - Advanced
Excel Interview Questions - Advanced
https://www.simplilearn.com/tutorials/excel-tutorial/excel-interview-questions
If you run the cells by passing the values as a reference, it will display 40 both the times. When we
pass arguments by reference, we are referencing the original value. The original value of x is
changed in the function.
When we pass the arguments by value, we are passing a copy to the function. The original value is
not changed. Hence, the second MsgBox will display the original value 10.
45. How do you find the last row and column in VBA?
To find the last row, use the below lines code in the VBA module:
Sub FindingLastRow()
Dim lastRow As Long
lastRow = ActiveSheet.Cells.SpecialCells(xlLastCell).Row
MsgBox (lastRow)
End Sub
To find the last column, use the below lines code in the VBA module:
Sub FindingLastColumn()
Dim lastRow As Long
4
lastColumn = ActiveSheet.Cells.SpecialCells(xlLastCell).Column
MsgBox (lastColumn)
End Sub
If strFileExists = “” Then
MsgBox “The selected file doesn't exist”
Else
MsgBox “The selected file exists”
End If
End Sub
47. Explain how to debug a VBA code?
To debug a VBA code line by line, you can use the F8 key. You can also create a breakpoint to
terminate the execution wherever you want.
The execution will start from the beginning of the code, and every time you press F8, it will execute
the next line and continue until the end of the code. The yellow arrow and the highlighted line tells
you the current point to execution.
divisors = divisors + 1
End If
Next i
If divisors = 2 Then
MsgBox number & “ is a prime number”
Else
MsgBox number & “ is not a prime number”
End If
End Sub
50. Write a VBA code to create a bar chart with the given data.
Consider the below data that has two features. You can use the lines of code below to create a bar
chart.
To create a drop-down list in Excel using data validation, first select the cell or cells where
you want the drop-down list to appear. Then, go to the "Data" tab on the ribbon and click on
"Validation". In the Data Validation dialog box, under the "Settings" tab, select "List" from
the "Allow:" dropdown menu.
In the "Source:" box, either type in the list items separated by commas, or click the up arrow
button to select a range of cells containing the items you want in your list. Ensure that the
"In-cell dropdown" box is checked. Click "OK" to apply the data validation and create your
drop-down list.
22. Can you extract the domain name from an email address?
Assume the email address is [email protected] in cell A1. Enter the following formula in
another cell (e.g., B1): =RIGHT(A1, LEN(A1) - FIND("@", A1)), which will yield
email.com.
FIND("@", A1) locates the position of the "@" character in the email address.
LEN(A1) calculates the total length of the email address.
Subtracting the position of "@" from the total length gives us the length of the
domain part.
Finally, RIGHT(A1, LEN(A1) - FIND("@", A1)) extracts the domain part from the
right side of the email address.
23. What are wildcards in Excel? How do you apply them?
In Excel, wildcards are special characters used in text searches and functions to represent one
or more characters, allowing for more flexible and powerful searching and matching.
The three main wildcards are the asterisk (*), which represents any number of characters, the
question mark (?), which represents a single character, and the tilde (~), which is used to
escape wildcard characters.
To apply a slicer to filter data in Excel, first, ensure your data is formatted as a table or is part
of a PivotTable. Click anywhere inside the table or PivotTable, then go to the ‘Insert’ tab on
the Ribbon and click on ‘Slicer’ in the Filters group. In the dialog box that appears, select the
checkbox for the column(s) you want to use for slicing, and then click ‘OK’. A slicer will
appear in your worksheet, which you can use to filter the data in the table or PivotTable by
simply clicking on the various options in the slicer.
7
Goal Seek in Excel is a tool that allows you to find the input value needed to achieve a
specific goal or target in a formula. It works by adjusting a single input value to make the
formula result match the desired outcome. You can access Goal Seek from the "Data" tab,
under the "What-If Analysis" button, where you specify the cell with the formula, the target
value, and the cell to change to achieve this target.
In the example below, we want to know what interest rate we'd pay if we made monthly
payments of $900 over a period of 15 years on a $100,000 loan. Goal Seek can help us figure
it out!
8
50. What is the difference between COUNT, COUNTA, COUNTBLANK and COUNTIF
functions?
COUNT: This function counts how many cells within a specified
range contain numerical data. It will ignore (not count) any cells
that are blank or contain text or symbols only.
COUNTIF: This function will count only the cells whose value meets
a certain condition specified by the user.
54. What are the alignments for Left, Right, Fill and Distributed?
The left/right alignment aligns the cell’s contents to the left and right.
Fill the cell with the same text repetitively, as the name suggests.
Distributed spreads the text over the cell width.
57. How do you extract the first name from a full name in Excel?
The FIND function will return the numerical location of this target
(with the first character of the text being 1). The LEFT function can
then extract the number of characters specified by the FIND
function from the beginning of the text (i.e the left).
However, the value returned by FIND will include the space itself, so
we need to subtract 1 from the value in order to find the actual
ending point of the first name. The formula would look like
this:=LEFT(A1,FIND(“ ”,A1)-1).
A second method would separate the first names and last names
and deposit them into separate new columns, using the Text to
Columns feature found in the Data tab. We covered this earlier
under how to split information in a column. The Text to Columns
dialogue box will allow you to select the delimiter separating each
field (e.g space) and show you a preview of the result. The last step
will allow you to choose where you want the result to be displayed.