web 2.0


Excel Highlight the Active Cell

In a video (http://www.youtube.com/watch?v=bGjqDGF7xaM) published on YouTube back in 2008, I explained how to highlight the active row in Excel. In this brief article, I discuss how you can highlight the active cell in Excel. In this particular case, I will only change the font color of the cell, but you can later change the conditional formatting and apply whatever formatting you wish.

Here's how it is done:

1. Create a named range called AddressOfActiveCell using the formula: =ADDRESS(5,6)
2. Select the entire worksheet and apply a conditional formatting using the formula (the active cell being A1 upon selection): =ADDRESS(ROW(A1),COLUMN(A1))=AddressOfActiveCell
3. Now, open the visual basic editor and insert the following code:


Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As
Range)

    With ThisWorkbook.Names("AddressOfActiveCell"
)
        .Name =
"AddressOfActiveCell"
       
.RefersToR1C1 = "=address(" & ActiveCell.Row & "," & ActiveCell.Column &
")"
   
End
With

End
Sub

Check the video tutorial here:

Tags: , , , , ,

Microsoft Excel - VBA

What is the factorial of 0.5 (0.5!)?

If you use Excel and enter the following formula: =FACT(0.5) the answer will be one. However, if you open a more rustic tool such as the Windows Calculator and try again, you will get 0.886226925510…

So, how can a tool such as the Windows calculator come up with the correct answer when Excel can only return 1? What about the factorial of 0.75 (0.75!)? Again, Excel returns 1 whereas the Windows calculator gets the correct answer: 0.919062526898...

Both numbers are close to one, but they are not exactly one.

The trouble is that Excel is using the general rule that states that the factorial is, in fact, the product of all integers in the series. So 4! Is given by =(4*3*2*1)=24. Unfortunately, the story does not end there for factorials.

When dealing with factorials the above works fine for integers. When dealing with non-integers (greater than zero), then we need the natural logarithm of the gamma function to get it to work. This function uses the concept of limits to determine the factorial of a number, so the factorial of 5 (5!) would be 119.99999998… when using gamma instead of the integer 120 (you can obviously round to 120, since it is effectively this number). For a discussion on the gamma function check this link: http://numbers.computation.free.fr/Constants/Miscellaneous/gammaFunction.html

Supposing the number you wish to find its factorial is located in cell A1, your formula using the gamma function would be:

=A1*EXP(GAMMALN(A1))

The last thing to rember is that this is for positive numbers only…

Tags: , , ,

Microsoft Excel

How to: Excel 2007 Conditional Formatting using formulas

Let us suppose that you have a list. In this list, you want to identify the cells that contain a certain text. Figure 1 shows the initial setup of our problem:



Figure 1 -
Conditionally formatting based on text in a cell

What we plan to do is to identify the products that contain the word “used” (for now). We show you two different ways to get this done.

In the first example, we type in the word directly into the formula. In the second example, we do this by using a validation list from where you can choose what to look for and then the CF is applied.

To begin with, choose the area containing the data (starting from the top-most cell). Add a new rule and choose the option Use a formula to determine which cells to format. In the formula box, you must enter the following formula: =IF(NOT(ISERROR(FIND("used",A1,1))),1,0)=1. Choose the formatting of your liking. Figure 2
shows the step visually:


Figure 2 -
Entering the conditional formatting formula

Obviously that, as it is, the conditional formatting is pretty much useless to us. What if we want to format whenever the word “new” comes up? Or when “repaired” comes up? In theses case it does not take a genious to figure out that we’re in serious trouble. It is simply not practical keep changing the value around everytime we need to conditionally format based on a word found in the text.

The solution is to implement a truly functional formula. In this case, we can use a data validation list to choose from (we discuss data validation in details in the second part of this eBooklet).

Here are the steps:

·        
Type in the word “repaired, used and new” in the range F1:F3;
·        
Select cell D1 where the data validation will be inserted;
·         Open the data validation tool (Data tab à Data tools group à Data Validation splitbutton à
Data validation button);
·        
From the Allow dropdown list, choose List;
·        
In the Source field, choose the range F1:F3;
·        
Click OK to finish.

Now, when you click on D1, you will get the validated list as shown in Figure 3
:


Figure 3 -
Validation list to be used in our conditional formatting

Now, all you need to do is to change the original formula to point to cell D1 as shown in
Figure 4:


Figure 4 -
Edited formula

If you are wondering above the “=1” at the end, we only added this to make it explicit that the formula is evaluating to 1 (true) so that the conditional formatting can be applied. There is not need to have the “=1” at the end of the formula. It is entirely up to you.

You can now select from the validated list any of the values and see your conditional formatting at work as shown in Figure 5
:


Figure 5 - Final step o four conditional formatting with data validation


You may also want to read this article (
http://www.excelguru.ca/blog/2009/04/23/making-an-icon-set-show-only-two-conditions/) from my fellow MVP, Ken Puls.

Tags: , , , , , ,

Microsoft Excel

Excel 2007: Diagonal Sum

In this tutorial I show you how to sum diagonally using an array formula. You will also learn how to add conditional formatting in order to track the diagonal being summed. In Excel, Array Formulas allows you to literally perform miracles. You only need to have a clear idea of what your objectives are. Enjoy!

Tags: , ,

Microsoft Excel