Sat 24 Jun 2017

## Excel Quiz 53

By |Saturday, June 24th, 2017|Categories: Quizzes||0 Comments

Sat 17 Jun 2017

## VBA - A Function to Check whether a Given Number is Prime

By |Saturday, June 17th, 2017|Categories: VBA||1 Comment

Below is an optimized function to check on the primality of a number. This function takes input number as Double, hence can be used to check upto a number having 15 significant digits. Whereas Long can take up to a maximum of 10 significant digits and maximum number it can support is 2,147,483,648.

First function is when pure number is passed, hence argument can be declared as Double. Hence, you will have to pass the value not the range.

Second function is when variant is passed as argument so that even range can be passed in this function.

```Function IsPrime(Num As Double) As Boolean
Dim i As Double
If Int(Num / 2) = (Num / 2) Then
Exit Function
Else
For i = 3 To Sqr(Num) Step 2
If Int(Num / i) = (Num / i) Then
Exit Function
End If
Next i
End If
IsPrime = True
End Function```
```Function IsPrimeV(Num) As Boolean
Dim i As Double
If Int(Num / 2) = (Num / 2) Then
Exit Function
Else
For i = 3 To Sqr(Num) Step 2
If Int(Num / i) = (Num / i) Then
Exit Function
End If
Next i
End If
IsPrimeV = True
End Function```

Below is time performance for both functions - The file used for checking time performance - Prime Number Checker

Tue 13 Jun 2017

## Solution 62 - Produce the Sum for Merged Cells Headers

By |Tuesday, June 13th, 2017|Categories: Solutions|Tags: , , , , , |0 Comments

Below is a possible solution for the challenge - Challenge 62 - Produce the Sum for Merged Cells Headers

Put following formula B14 and drag right and down

=SUM(OFFSET(\$A\$1,ROWS(\$1:1),MATCH(B\$13,\$1:\$1,0)-1,,IFERROR(MATCH(C\$13,\$1:\$1,0),COUNTA(\$2:\$2)+1)-MATCH(B\$13,\$1:\$1,0)))

Sat 10 Jun 2017

## Challenge 63 - Convert to Date Format

By |Saturday, June 10th, 2017|Categories: Challenges|Tags: , , , , , , , , , , , |1 Comment

This time, you have been given a file containing Text dates into various formats. The challenge before you is to write a single formula to convert them into an appropriate date format.

The challenge file can be downloaded from Challenge 63 - Convert to Date Format The solution to the above challenge will be published after a month i.e. on 10-Jul-17.

Sat 03 Jun 2017

## Tips & Tricks 160 - When is Labor Day in a Given Year

By |Saturday, June 03rd, 2017|Categories: Tips and Tricks||0 Comments

While 1st May is celebrated as Labour Day in most of the countries but in USA/Canada, it is celebrated on 1st Monday of September.

Suppose the year is given in cell A1, you can use following formula to calculate the date for Labor Day

=CEILING(DATE(A1,9,1)-2,7)+2

Note - This utilizes the knowledge gained in Article 34 - Show Date for a Coming or Previous Day (Say Coming Monday, Previous Friday) 