Thursday, May 28, 2009

Folder and File Option : Missing Security Tab: Windows XP

Problem: Right clicking on folder or file not showing security tab:


Go to Explorer -> tools -> folder options -> View->

navigate to the last check box in the list “USE SIMPLE FILE SHARING” .

Uncheck this checkbox and click OK.

Now you will be able to see the security tab in file properties.

Friday, April 13, 2007

Allow only numeric value in a textbox on a form

Remove //** From the html codes:

This is the function in the header tag

function AllowNumeric(e) {
var iKeyCode = 0;
if (window.event)
iKeyCode = window.event.keyCode
else if (e)
iKeyCode = e.which;
if (iKeyCode > 47 && iKeyCode < 58)
return true
else
return false;

Here is the HTML for the textbox

//////(<)//**
INPUT onkeypress="javascript: return AllowNumeric(event);" id="txtAcctNo" style="WIDTH: 120px; HEIGHT: 20px"
type="text" maxLength="8" runat="server" size="14"
//**>///////

Wednesday, August 16, 2006

The VLOOKUP Function:Very useful and very simple








The most useful and least used in common practice due to lack of knowledge is the VLOOKUP function of MS Excel.
Here I am presenting with the help of one example the common use of VLOOKUP function.
Let us first see the function:
With the VLOOKUP function, ypu can look for specified data in the first column of a table. The result is returned from the column number specified, if found.The formula for VLOOKUP is:

=vlookup(lookup_value,table_array,col_index_num,range_lookup)



Let us look at the example, I want to see if value in column A3 to A6 of table A exist in Table B.If yes, I want formula to return me column E's value.
The formula is:

=+VLOOKUP(A3,$E$3:$F$6,1,FALSE)

Now, here I am looking for A3(lookup_value) of table A in E3 to F6(table_array), remember: it will look into left most column,so in E3 to E6,and return me value from column 1(col_index_num) which is E3 to E6.Then comes the range_lookup which is False.The Reason for it being False is,the use of False as the optional range_lookup Argument. This directs to the VLOOKUP to find an exact match and is most often needed when looking for a text match. If this is omitted, or True, you will often get unwanted results when searching for text that is in an unsorted column of data. When True is used, or the range_lookup Argument is ignored, the data should be sorted (by the first column) in ascending order.

See the results in column A8 to A11.

Now, if I want to return the value from column F of Table B, all I have to do is to change column index to 2.

=+VLOOKUP(A3,$E$3:$F$6,2,FALSE)

See the results in column D8 to D11.

Whenever, match is not found, the formula will retorn an error i.e. #N/A.To avoid this, i write another formula:

=IF(ISERROR(+VLOOKUP(A3,$E$3:$F$6,1,FALSE))=TRUE,0,(+VLOOKUP(A3,$E$3:$F$6,1,FALSE)))

Meaning that if vlookup returns error i.e. #N/A, then return 0 else return vlookup value.
That is all to it.Hope you find it useful.

Friday, October 28, 2005

Export Custom Outlook Form Data to MS Access

Dim appAccess
Dim nms
Dim strFolder
Dim fld
Dim strAccessPath
Dim rst
Dim dbe
Dim wks
Dim dbs
Dim itms
Dim itm

Sub CommandButton1_Click()

Set nms = Application.GetNamespace("MAPI")
strFolder = "fbtest folder"
Set fld = nms.Folders("Personal Folders").Folders(strFolder)

'Pick up path to Access database directory from Access SysCmd function
Set appAccess = CreateObject("Access.Application")
strAccessPath = appAccess.SysCmd(9)

'Get DAO version from DBEngine
strDBEngine = appAccess.Application.DBEngine.Version

'MsgBox "DBEngine version: " & strDBEngine

appAccess.Quit

If strDBEngine = "3.51" Then
'Office 97 DAO version
Set dbe = CreateObject("DAO.DBEngine.35")
strDBName = strAccessPath & "fbtestdb.mdb"
ElseIf strDBEngine = "3.6" Then
'Office 2000 DAO version
Set dbe = CreateObject("DAO.DBEngine.36")
strDBName = strAccessPath & "fbtestdb.mdb"

Else

MsgBox "Unknown Office version; canceling"

Exit Sub

End If
'MsgBox "DBName: " & strDBName
Set wks = dbe.Workspaces(0)
Set dbs = wks.OpenDatabase("S:\sameer\fbtestdb.mdb")

'Open Access table containing contact data
Set rst = dbs.OpenRecordset("fbtesttable")
'Set up reference to Outlook folder of items to export

Set itms = fld.Items
ItemCount = itms.Count
If ItemCount = 0 Then
MsgBox "No FB requests to export"

Exit Sub
Else

MsgBox ItemCount & " FB requests to export"

End If
'Set up reference to Outlook folder of items to export
Set itms = fld.Items
ItemCount = itms.Count

If ItemCount = 0 Then

MsgBox "No Fund Builder requests to export"

Exit Sub
Else

MsgBox ItemCount & " FB requests to export"

End If
For Each itm In itms

rst.AddNew

'Custom Outlook properties
rst.Request=itm.userproperties("001 Request")
rst.AccountNumber=itm.userproperties("002 Account Number") rst.ClientName=itm.userproperties("002 Client Name")

rst.Update

Next

rst.Close

MsgBox "All FB requests exported!"

End Sub

Export Data From Outlook Custom Form to Excel

Sub CommandButton1_Click()
ExportToExcel()
End Sub

Sub ExportToExcel()

Dim appExcel
Dim olMAPI
Dim strTemplatePath
Dim strSheet
Dim Ifld
Dim MItem

Set olMAPI = GetObject("", "Outlook.Application").GetNameSpace("MAPI")
Set Ifld = olMAPI.Folders("Personal Folders").Folders("SamTest")

i=1

'Pick up Template path from the word options dialog
strTemplatePath="H:\"

'Debug.Print "Document folder: " & strTemplatePath

strSheet="SameerTest.xls"
strSheet=strTemplatePath & strSheet

'Set appExcel= New Excel.Application
Set appExcel=GetObject("", "Excel.Application")

appExcel.Workbooks.Open (strSheet)
Set wkb = appExcel.ActiveWorkBook
Set wks =wkb.Sheets(1)
wks.Activate
wks.Cells(1, 1)="Subject"
wks.Cells(1,2)="ClientName"
wks.Cells(1,3)="ClientAddress"
wks.Cells(1,4)="ClientAge"

appExcel.Application.Visible=TrueFor Each MItem In Ifld.Items

If Left(MItem.Subject, 12) = "Client Form" Then
i = i + 1

If MItem.Subject<>"" Then
wks.Cells(i,1).Value = MItem.Subject
End If

If MItem.UserProperties("010 ClientName").Value<>"" Then
wks.Cells(i,2).Value = MItem.UserProperties("010 ClientName").Value
End If

If MItem.UserProperties("020 ClientFirstName").Value<>"" Then
wks.Cells(i,3).Value = MItem.UserProperties("020 ClientAddress").Value
End If

If MItem.UserProperties("030 ClientInitial").Value<>"" Then
wks.Cells(i,4).Value = MItem.UserProperties("030 ClientAge").Value
End If End If

Next

Set MItem = Nothing
Set Ifld = Nothing
Set strTemplatePath = Nothing
Set strSheet = Nothing
Set olMAPI = Nothing
Set appExcel = Nothing

End Sub

Wednesday, September 07, 2005

Counting Commas or Special characters in a cell

Suppose, your names seperated by "," is in cell A4.

Here is the formula to calculate number of commas in the cell A4:

=LEN(A4)-LEN(SUBSTITUTE(A4,",",""))


The first part: LEN(A4) calculates length of string with commas.


The Second part: LEN(SUBSTITUTE(A4,",","")) calculates length of string without commas.

The differnece of the two i.e. first part-second part will give you number of commas in your string.

This formula can come out handy in many calculations.

Monday, August 22, 2005

VB 6.0-Some Formatting Expression

I find it very handy:

Formatting numbers with named formats Expression Result
Format(35988.3708, "general number") 35988.3708
Format(35988.3708, "currency") $35,988.37
Format(-35988.3708, "currency") ($35,988.37)
Format(35988.3708, "fixed") 35988.37
Format(1, "fixed") 1.00
Format(35988.3708, "standard") 35,988.37
Format(1, "standard") 1.00
Format(0.35988, "percent") 35.99%
Format(0, "Yes/No") No
Format(0.35988, "Yes/No") Yes
Format(0, "True/False") False
Format(342, "True/False") True
Format(0, "On/Off") Off
Format(-1, "On/Off") On


Formatting numbers with special characters Expression Result
Format(35988.3708, "00000.0") 35988.4
Format(35988.3708, "0000000.0") 0035988.4
Format(35988.3708, "00,000.00000") 35,988.37080)
Format(6.07, "0.###") 6.07
Format(6.07, "0.000##") 6.070
Format(143879, "#,###,###.00") 143,879.00

Formatting numbers with embedded characters Expression Result
Format(45, "\[00\]") [45]
Format(642, "\£000.00") £642.00
Format(99, "00\¢") 99¢
Format(8, "#0\).") 8).

Formatting dates and time

Format(36715.5784, "general date") 7/8/00 1:52:54 PM
Format(36715.5784, "short date") 7/8/00
Format(36715.5784, "medium date") 08-Jul-00
Format(36715.5784, "long date") Saturday, July 08, 2000
Format(36715.5784, "short time") 13:52
Format(36715.5784, "medium time") 01:52 PM
Format(36715.5784, "long time") 1:52:54 PM
Format(36715.5784, "c") 7/8/00 1:52:54 PM
Format(36715.5784, "d") 8
Format(36715.5784, "dd") 08
Format(36715.5784, "ddd") Sat
Format(36715.5784, "dddd") Saturday
Format(36715.5784, "ddddd") 7/8/00
Format(36715.5784, "dddddd") Saturday, July 08, 2000
Format(36715.5784, "w") 7
Format(36715.5784, "ww") 28
Format(36715.5784, "m") 7
Format(36715.5784, "mm") 07
Format(36715.5784, "mmm") Jul
Format(36715.5784, "mmmm") July
Format(36715.5784, "q") 3
Format(36715.5784, "y") 190
Format(36715.5784, "yy") 00
Format(36715.5784, "yyyy") 2000
Format(36715.5784, "h") 13
Format(36715.5784, "hh") 13
Format(36715.5784, "n") 52
Format(36715.5784, "nn") 52
Format(36715.5784, "s") 54
Format(36715.5784, "ss") 54
Format(36715.5784, "ttttt") 1:52:54 PM
Format(36715.5784, "AM/PM") PM
Format(36715.5784, "am/pm") pm
Format(36715.5784, "A/P") P
Format(36715.5784, "a/p") p
Format(36715.5784, "AMPM") PM

Format "w" returns day of week (1 = Sunday, 7 = Saturday)
Format "ww" returns week of year (1-53)
Format "y" returns day of year (1-366)
Format "h" returns hour of day as one or two digits...if necessary
Format "hh" returns hour of day as two digits...definitely
Above applies to "n"/"nn", and "s"/"ss" as well
Format "AMPM" uses settings from WIN.INI [intl] s1159=AM, s2359=PM
Try mixing and matching the format strings Expression Result
Format(36715.5784, "m-d-yy") 7-8-00
Format(36715.5784, "d-mmmm-y") 8-July-00
Format(36715.5784, "mmmm yyyy") July 2000
Format(36715.5784, "hh:mm a/p") 01:52 p
Format(36715.5784, "m/d/yy h:mm") 7/8/00 13:52

FormatDateTime
This new function works about the same as the regular Format function, but you're only allowed to
use one of 5 constants -
vbGeneralDate, vbLongDate, vbShortDate, vbLongTime, vbShortTime.

Sunday, April 17, 2005

MS Excel: Working in multi-sheet environment

When we are referencing one sheet data to another sheet in a formula or otherwise comparing multi sheets in a work book, it becomes tedious to move from sheet to sheet back and forth. Think of a situation where you have to refer data from three or four sheet.

Wouldn't it be nice, if you can have all those three sheets of workbook open side by side?
Did you know that there is an easy way to do this and I always find it very handy while working on a multi-sheet workbook?

Open your workbook, sheet1.

Go to Window tab,
Click on New Window,
Select sheet 2 on this newly opened workbook where you will see on the top with the name: 2.




Again repeat the same steps and open sheet 3. Here with the name, you will see: 3.

Now, that you have the same workbook opened thrice with different sheets,

Go to window,
Click arrange,
Select Vertical

and here you go, three sheet of same workbook opened side by side, toggle around and enjoy working on multi-sheet workbook.

Thursday, March 31, 2005

MS Excel: Close all Open Workbooks

At times, when you have many workbook open on your desktop and wish to close all of them together,there is an easy way in MS Excel to do this. I could never understand the reason why this option is not on main menu and is kept hidden.
Follow this:

Press Shift key on the keyboard while clicking File on the menu;

And now you will see the option: Close All

Click on it and all the workbooks are closed unless, in some workbook(s), you have made changes and not saved them.Excel will prompt you to save changes and close the workbooks.

Wednesday, March 30, 2005

MS Excel: Not only sort data in a column but also in the rows

Click a cell of the row you want to sort horizontally.

Select Sort from the Data menu.

In the Sort dialog box, click on the Options.

In the Sort Options dialog box, click on Sort Left to Right, then click OK.

Back in the Sort dialog box, go to the Sort By combo box and select a row to sort, and also select the direction (ascending or descending).

You can select additional rows by going to the boxes.

Click OK.
Yu Hooo!!! Excel sorts the row horizontally.

Tuesday, March 29, 2005

MS Excel: Get Summary Calculations on the Fly

As a busy executive, you are presented with lots of data in MS Excel format. Though you know the formulas to calculate and find results, but it is just a waste of time to write formula to see what the sum of particular range is or which is the highest value or lowest value or may be the average.
While looking at the spreadsheet, you can do the following to improve your analysis capabilities or effectively respond to one off questions which keeps coming up during meetings:


1. From the menu option, select View, and check the status bar.





2. This action will start showing you status bar at the bottom of spreadsheet.

3. Select the range of data you wish to analyze, and you will see on the status bar, Sum= 100 or whatever is the sum of the range selected (By default, excel is set to show Sum).

4. Right click on status bar, and you will see options like Average, Count, Count Nums, Max, Min and Sum. Select any one and see the result on status bar.


Monday, March 28, 2005

MS Excel: Sum of a column with #DIV/0! Or any other error message in some cells

My friend recently requested me to suggest some quick fix for sum of a column which has few cells containing #DIV/0! Or any other error message. Doing the sum function produces error because sum neither ignores those cells nor understands it.

My process to deal with this problem is:

1.Insert a column next to the column you are trying to sum up.
2.In my example, the first cell is A3, I inserted column B.
3.In Cell B3, I wrote the formula “=IF (ISERROR (A3), 0,A3)”
4.This formula looks for the cell value and if it is an error, converts it to 0.
5.Then I copied this formula in B4 to B6 since my values were in up to cell B6, you could copy it till last cell value.
6.Select Cells B3 to B6, copy and paste special-values only.
7.Now you can sum this column and you are done.

Example:
Formulas:



Values:

Saturday, March 26, 2005

MS Excel and VBA: Transposing Data


This tip is submitted by Anupam Srivastava:

Transposing Data from Column to Row with a feature to start a New Row for each New Record which is identified by an empty Row:

The original dataset was stored in the same column followed by an empty row before each new group entry. The task was to bring each dataset into row format to make data analysis job easier. This is particularly useful for comparing information.
This Macro scans through the column, copies each item and paste it into different columns in the same row and begins a new row for each empty row it finds. The datasets are differentiated by empty row before new dataset begins.
To maintain consistency with the generated table, it is wise to make sure that each new dataset has the same number of data entities (items).

For users with knowledge of DB, if we consider each group to be an attribute with x number of entities, then each new attribute that you add to the original data should consist x entities to make sure that the final table gets populated in a uniform fashion.

For this Macro it is assumed that each dataset consists of 7 entities


Sub DataTranspose()

‘ Declare variable to denote column and row assignment

' Row Variable
Dim i As Integer
' Column Variable
Dim j As Integer
i = 2
j = 1


' Sheet has 218 rows of data

For i = 1 To 218
Range("A" & i).Select
Selection.Copy
Range("a" & j).Select
ActiveSheet.Paste

' Increment Row Counter to read next row
i = i + 1
Range("A" & i).Select
Selection.Copy

' Transposing Row Entry to Column
Range("B" & j).Select
ActiveSheet.Paste
i = i + 1
Range("A" & i).Select
Selection.Copy
Range("C" & j).Select
ActiveSheet.Paste
i = i + 1
Range("A" & i).Select
Selection.Copy
Range("D" & j).Select
ActiveSheet.Paste
i = i + 1
Range("A" & i).Select
Selection.Copy
Range("E" & j).Select
ActiveSheet.Paste
i = i + 1
Range("A" & i).Select
Selection.Copy
Range("F" & j).Select
ActiveSheet.Paste
i = i + 1
Range("A" & i).Select
Selection.Copy
Range("G" & j).Select
ActiveSheet.Paste
i = i + 1
Range("A" & i).Select
Selection.Copy
Range("H" & j).Select
ActiveSheet.Paste
i = i + 1
Range("A" & i).Select
Selection.Copy
Range("I" & j).Select
ActiveSheet.Paste
i = i + 1
j = j + 1
Next

End Sub


----------------------------------------------------------------------------------
Anupam Srivastava is B.Sc. (Computer Engineering) from Queen’s University, Kingston, Canada.

Friday, March 25, 2005

MS Excel: Always show full menu

Turn off the frequently used menu option and always use full menu option during your learning process of MS Excel and remember, learning is a continuous process and you are always learning. So make the full menu option as a regular option for you.
MS Excel only shows you frequently used menu under each tab and then, if you wish to use something other than shown in the menu, you have to go to that expand sign to see full menu:




This is frustrating, especially when you are learning. How are you suppose to know, what is hidden under that magic expand sign. I always prefer to keep full menu on.
To do this, it is a very simple two step process:

Step 1: Go to Tools, find out Customize and click:





Now, you will see something like this:





Step 2: Click on Options tab and select, always show full menus, close and you are done.

Now, every time you click on a menu, you will see full menu. Remember, by doing this on MS Excel, your all other MS Office programs like MS Words etc. will also show full menu items and it is not possible to avoid this. But who cares, it is always good to keep full menu in view irrespective of program you are using.

Thursday, March 24, 2005

MS Excel : The Leading Zeros

MS Excel keeps removing that leading zero from your number?
Excel automatically sees the data as a number and leading zeros have no value in numbers, so it gets rid of them.
It is helpful when you're actually dealing with numbers, but irritating when it's a Item number or Employee number.
There is a quick way to get Excel to leave your zeros alone. Justchange the cell format to text. There are couple of ways to make this change—
1. Highlight the cells to change.
Then go to the Format menu, Cells choice. (Ctrl + 1 works too.)
On the General tab choose Text from the Categories list.
Click OK.
The leading zeros are there.
2.If you only have a few cells to change you could just type an apostrophe before entering the data (ie. instead of typing 01122 in the cell type '011122).
When you hit the Enter key the change is made instantly, for that cell only, and again your zero is there.

Monday, March 21, 2005

Outlook SaveAs Type Constants

Constant Value
olTXT 0
olRTF 1
olTemplate 2
olMSG 3
olDoc 4
olHTML 5
olVCard 6
olVCal 7

Monday, January 17, 2005

SQL db to MS Access-How to

Go To SQL Enterprise Manager
>>> Select Server
>>>Open DB
>>>>Tools
>>> Export.. and it will guide you through from there.Don't remember, you probably have to disconnect as well.
Try disconnecting and then, don't forget to connect back. :)

Saturday, December 18, 2004

MS Excel:Quickly Navigate Multi-Sheet Workbooks

Right-click the the arrow buttons at the bottom left-hand side of the screen (the sheet tab navigation tool). You'll get a clickable menu of all the sheets in the workbook.

Friday, December 17, 2004

MS Excel:Search for an Asterisk, Question Mark, or Tilde

Since these characters have special meanings in Excel, you will need to precede them with a tilde to be able to search for them successfully.
So, to find an asterisk, Edit>Find, and then type ~* in the Find dialog box;
to find a tilde, type ~~;
to find a question mark, type ~?.

Thursday, December 16, 2004

MS Excel:Change Text Case

Excel provides three handy functions to change the case of text.
UPPER: converts all text to uppercase
LOWER: converts all text to lowercase
PROPER: converts text to The First Letter Of Each Word Is Capitalized.
If cell A1 contains the text: sameer lal, the following formula will produce Sameer Lal.
=PROPER(A1)
You may want to then select the cell or the range, Copy and then Edit>Paste Special (then choose Values) to change the contents of the cells from functions into the values produced by the functions.

Wednesday, December 15, 2004

MS Excel: Formula Error and What It refers To

When you get an error in your formula cell, you’ll need to determine what caused the error and fix it.
Common Formula Errors You’ll See in EXCEL
What Appears in the Cell and What happened? :


#DIV/0!
Appears when the formula calls for division by a cell that either contains the value 0 or, as is more often the case, is empty. Division by zero is a no-no.

#NAME?
Appears when the formula refers to a range name that doesn't exist in the worksheet. This error value appears when you type the wrong range name or fail to enclose in quotation marks some text used in the formula, causing Excel to think that the text refers to a range name.

#NULL!
Appears most often when you insert a space (where you should have used a comma) to separate cell references used as arguments for functions.

#NUM!
Appears when Excel encounters a problem with a number in the formula, such as the wrong type of argument in an Excel function or a calculation that produces a number too large or too small to be represented in the worksheet.

#REF!
Appears when Excel encounters an invalid cell reference, such as when you delete a cell referred to in a formula or paste cells over the cells referred to in a formula.

#VALUE!
Appears when you use the wrong type of argument or operator in a function, or when you call for a mathematical operation that refers to cells that contain text entries.


Tuesday, December 14, 2004

MS Excel:Remembering Cell Names

When you're doing a formula and can't remember the range names that you need, you can:

Press [F3] - (a list of range name appear)

DOUBLE CLICK the range name that you want to include in formula.


Monday, December 13, 2004

MS Excel: Quick Click Movement

If you Want to find out where a column ends or where the next blank cell is in the column.

Select a cell:
Double-click the bottom edge of the selected cell,
(Take cursor to botton edge and when it becomes + sign made of four arrows)
and you're taken to the last filled cell below the selected cell in the current column.
This trick works for rows nd column and in all four directions.
So, for example, if you want to find the last filled cell or the next empty cell in the current row:

Select a cell:
Double-click the right edge of the cell.

Sunday, December 12, 2004

MS Excel:Range Names Used In Formulas

Named ranges let you calculate the total for all cells in a range with a formula such as

SUM(Value) instead of SUM(E2:E20)
For example, enter the name Quantity for Column C and Price for column D and value in column E.(highlight the column from C2:C20 and then type the name in the Range name text area at the left of the fx symbol and hit Enter).
Then enter the formula =Quantity*Price in column E cells.
Now, as you fill in numbers in the Quantities and Price columns, Excel automatically calculates Values in the third column.

Saturday, December 11, 2004

MS Excel: Avoid error displays in formulas

Sometimes a formula may return an error message
but you may want to avoid the messages.
You can do so by using an IF() function to check for an error.
The formula below displays a blank if the division results in an error.


=IF(ISERROR(A1/B1),"",A1/B1)

Friday, December 10, 2004

MS Excel: Indirect Function

Excel's INDIRECT function accepts a text string as an argument,and then evaluates the text string to arrive at a cell or range reference.Assume that cells B2,C2,D2 on our Master worksheet hold the student's name.
The following formula utilizes the INDIRECT function to create the range reference used by the SUM function(Cell B2 to B6 carry individual marks for each subjecton different sheets named after students referred in B2 to D2):


=SUM(INDIRECT(B2&"!$B$2:$B$6"))

Note that the ampersand operator to join the student name with the cell reference (expressed as text).Refer the example below:The cell B2 contains the text Sam,the SUM function returns the sum of the range Sam!B1:B6.


Thursday, December 09, 2004

MS Excel: Copy formula shortcut

If you have some formula in cell A3, go to cell A4 and press Ctrl+D and the formula will be copied there in cell A4.Similarly, cover cell A3 to A15, and press Ctrl+D, the formula will be copied from A4 to A15

.Same thing you can perform in right cell to the cell of formula by pressing Ctrl+R, in our case, B3.

This tip is contributed by Pramod Jain

Wednesday, December 08, 2004

MS Excel:Cell Counting Techniques

Excel provides many ways to count cells in a range that meet various criteria:

  • The DCOUNT function. The data must be set up in a table, and a separate criterion range is required.
  • The COUNT function. Simply counts the number of cells in a range that contain a number.
  • The COUNTA function. Counts the number of non-empty cells in a range.
  • The COUNTBLANK function. Counts the number of empty cells in a range.
  • The COUNTIF function. Very flexible, but often not quite flexible enough.

Tuesday, December 07, 2004

MS Excel:Calculate the day of the year and days remaining

If you've ever had to figure out which of the year's 365 days a particular date falls on, or how many days remain in the year, you've probably found that Excel lacks functions to perform the calculation. But you can create formulas to do the job.
The formula below returns the day of the year for a date in cell A1:


=A1-DATE(YEAR(A1),1,0)

Note: Excel automatically formats the cell as a date, so change the number format to another option (like General).
To calculate the number of days remaining in the year (assuming that the date is in cell A1), use the following formula:

=DATE(YEAR(A1),12,31)-A1




Monday, December 06, 2004

MS Excel:Count AutoFiltered Rows

AutoFiltering a list hides rows that don't meet your filter criteria. After applying filtering criteria, Excel shows the record count on the status bar--but this value disappears when the sheet is calculated.
To display a permanent count of the visible rows in an AutoFiltered list, create a formula using Excel's SUBTOTAL function. The first argument for SUBTOTAL specifies the type of operation (an argument of 2 displays a count of the visible cells in a range).The formula in cell which will display visible rows is:


=SUBTOTAL(2,A6:A3000)

The formula counts the number of visible cells in the range (minus the header row). Apply different filtering criteria, and the formula updates to show the new count. The SUBTOTAL function only works for AutoFiltering and outlining. If you hide rows manually, it won't return the correct result.


Sunday, December 05, 2004

MS Excel:Calculating a conditional average

In the real world, a simple average often isn't adequate for your needs.
For example, an instructor might calculate student grades by averaging a series of test scores but omitting the two lowest scores. Or you might want to compute an average that ignores both the highest and lowest values.
In cases such as these, the AVERAGE function won't do, so you must create a more complex formula. The following Excel formula computes the average of the values contained in a range named "scores," but excludes the highest and lowest values:


=(SUM(scores)-MIN(scores)-MAX(scores))/(COUNT(scores)-2)

Here's an example that calculates an average excluding the two lowest scores:

=(SUM(scores)-MIN(scores)-SMALL(scores,2))/(COUNT(scores)-2)