Nick's guide to Excel / VBA Interview Questions

Nick's picture

I have hosted hundreds of Excel / VBA interviews, and I can work out very quickly how good someone is.

The biggest blunder to make in an interview is to say something like: "Oh, that's easy, I can do that in 5 minutes with the compiler and help files"

Well, in my interview, you have no compiler and no help files, so don't ignore syntax, or rely too much on help files.

You wouldn't turn up to a French interview with a dictionary and translate every word now would you ?

; - >

Here are some Excel VBA interview questions I might ask you.. Add a comment if you think you have a good answer.

First day

=TEXT(WEEKDAY(TODAY()-DAY(TODAY()-1)),"dddd")

Nick's picture

First day of the month

that's the day of the week of the first day of the current month

First day

I seem to have problems with these questions!  What else should the answer display?

First Day

If I understand the question right - below is the number of days in current year starting from Jan 1 to the first day of this month (including)

=DAYS360(DATE(YEAR(NOW()),1,1),DATE(YEAR(NOW()),MONTH(NOW()),1))

Nick's picture

First Day

maybe I need to clarify

The first day of the current month right now is: 1st May 2009

The it will be only the part

The it will be only the part of the above:
=DATE(YEAR(NOW()),MONTH(NOW()),1)

Nick's picture

1st day

is correct... u cld also use TODAY instead of NOW.

1st day

you could also use =eomonth(today(),-1)+1

Nick's picture

3. VBA Range Selection Question

You have the following data:
Data

- A1 is always populated
- the rest of the data may change
- write a VBA subroutine that selects A1 and up to and including the last populated cell on the diagonal going downwards and to the right.

So in this case: it will select A1:D4
Data

How about this solution

Private Sub DiagSelect()
Dim colCount As Long
'Get the last column populated with data
colCount = ActiveSheet.UsedRange.Columns.Count

ActiveSheet.Range("A1", ActiveSheet.Cells(ActiveSheet.Rows.CountLarge, colCount).End(xlUp).Address).Select

End Sub