October 21st, 2008 | Categories: VBA | Tags: , ,

This is the opposite tutorial of the Converting a Single Row Vector into a Matrix tutorial.
The following function will take a range as a matrix and convert it to a single column vector:
Option Explicit
Function Create_Vector(Matrix_Range As Range) As Variant
Dim No_of_Cols As Integer, No_Of_Rows As Integer
Dim i As Integer
Dim j As Integer
Dim Cell
No_of_Cols = Matrix_Range.Columns.Count
No_Of_Rows = [...]

2 comments (3,590 views)
October 20th, 2008 | Categories: Formulas | Tags: , , , ,

Imagine that we have a list of names such as:

And we want to give each one a unique identifier:

So that the first name Bob has the identifier 1, and the next Mark has the identifier 2. This can be achieved by the following process.
We assign Bob (i.e the first person in the list) with an [...]

5 comments (4,007 views)
October 19th, 2008 | Categories: Formulas | Tags: , ,

Excel’s SUBSTITUTE function allows us to substitute part of a string with another part:
SUBSTITUTE(String,”Old Text”,”New Text”,occurrence”)
Where:
• String is the string that we are working with
• “Old Text” is the text that we want to eliminate
• “New Text” is the text that we want to incorporate
• Occurrence is which instance of the old text we wish [...]

0 comments (632 views)
October 18th, 2008 | Categories: VBA | Tags: , , , ,

This is the opposite tutorial of the Convert Matrix to Vector tutorial.
The following function takes a single row vector and converts into a matrix:
Function Create_Matrix(Vector_Range As Range, No_Of_Cols_in_output As Integer, No_of_Rows_in_output As Integer) As Variant
ReDim Temp_Array(No_Of_Cols_in_output, No_of_Rows_in_output)
Dim No_Of_Elements_In_Vector As Integer
Dim Col_Count As Integer, Row_Count As Integer
Dim Cell
No_Of_Elements_In_Vector = Vector_Range.Rows.Count
‘Eliminate NULL Conditions
If Vector_Range Is Nothing Then [...]

4 comments (1,545 views)
October 16th, 2008 | Categories: Cells, Columns & Rows | Tags: , , ,

The following function will return the Maximum Value in each Column in a Range:
Function Max_Each_Column(Data_Range As Range) As Variant
Dim TempArray() As Double, i As Long
If Data_Range Is Nothing Then Exit Function
With Data_Range
[...]

0 comments (1,626 views)
October 15th, 2008 | Categories: Charts, VBA | Tags: , ,

The following tutorial will describe how to create a bar chart using VBA.
Steps:
1. Enter the VBA project window by right clicking on a sheet name and selecting “View Code” or by selecting “ALT, F11”.
2. On the right hand side, right click on your project name and select inset “module”.
3. Copy and paste the following [...]

2 comments (2,470 views)
October 15th, 2008 | Categories: Data, Formulas, General | Tags: ,

A simple way to add a comment to a formula for later reference is to add the following to the formula N+(“YOUR COMMENT”). By way of an example, =SUM(A2:A4)+N(“This is”).

4 comments (1,254 views)
October 14th, 2008 | Categories: Cells, Columns & Rows | Tags: , , ,

The following Subroutine will delete each row in a range where the value in Column A begins with a prescribed piece of text:
Sub Delete_Rows(Data_range As Range, Text As String)
Dim Row_Counter As Integer
For Row_Counter = Data_range.Rows.Count To 1 Step -1
If Data_range Is Nothing Then
Exit Sub
End If
If UCase(Left(Data_range.Cells(Row_Counter, 1).Value, Len(Text))) = UCase(Text) Then
[...]

0 comments (1,671 views)
October 14th, 2008 | Categories: Formulas | Tags: , , , ,

Consider the following two lists:

And that we want to see which items from column A are in Column B. This can be achieved by the MATCH function in conjunction with ISNUMBER .
The MATCH function has the following syntax:
MATCH(A6,C4:C13,0)
And this will return the position of the value cell A6 in the range C4:C13 – the “0” [...]

1 comment (945 views)
October 13th, 2008 | Categories: Cells, Columns & Rows | Tags: , , ,

The following subroutine will highlight all the duplicate values in range in yellow. It does not matter whether the values are text or numbers. It uses Excel’s COUNTIF function to count up the duplicates and then sets the colour to yellow:
Sub Highlight_Duplicates(Values As Range)
Dim Cell

For Each Cell In Values
If WorksheetFunction.CountIf(Values, Cell.Value) [...]

0 comments (3,162 views)