Remove Non-AlphaNumeric Characters from String

The function below will allow us to remove a non alphanumeric character from an input string.
Be careful though, lengther the string, more time needed to evaluate each string on the sentence.
To bad that I don’t have any idea on how to use Regular Expression in Excel VBA, if we can use regex to replace [...]

Tags: ,


Create New Excel Worksheet With VBA

The Excel VBA macro below will create a new Excel Worksheet called ‘RawData’ or we can use msgbox to ask for the Worksheet name if needed.
If there is already a Worksheet called RawData, user will be ask whether they want to use the old Worksheet and cancel new Worksheet creation, or delete the old Worksheet [...]

Tags: , , , , , , , , , , , , , ,


How To Find the Last Row That Contain Data in Excel?

UPDATE June 13, 2008:
Another alternative way to find the last row with data :
Function LastRow() As Long
Dim ix As Long
ix = ActiveSheet.UsedRange.Row – 1 + ActiveSheet.UsedRange.Rows.Count
LastRow = ix
End Function
I did a simple test, and the function will return the correct last row position [...]

Tags: , , , , , , , , , , , , , , ,


VBA Delete Excel Rows Based on Certain Date

Let say I have a bunch of formatted data in my Excel sheet, and in Column A I have a dates. Then I wanna filter all the data base on certain date, for example 1 Jan 2009, and delete all others data before that date.
The algorithm is like this: I’ll create a loop from the [...]

Tags: , , , , , , ,


Number of Cells/Rows/Columns With Formula

A few weeks ago I received this question from someone called LS:
Hi
I want to write a macro that counts the following
- Number of cells with formula
- Number of Rows with formula
- Number of Columns with formula
Please let me know if there is a way of doing it in Excel VBA
To find out the number of [...]

Tags: , , , , , , , , , ,


How To Hide an Excel Worksheet

Some time we want to hide a certain Excel Worksheet from view, and it’s a common practice to use select the Worksheet, go to menu Format > Sheet > Hide.
Using the method explained above is right, but unfortunately, others people can easily unhide the Worksheet using the same method, only this time, instead of selecting [...]

Tags: , , , , , , , , , , , , , , , , , , , , , , , ,


How to get an Acronym using Excel VBA?

The purpose of the following example of Excel VBA macro is to get the acronym or an abbreviation of each of the first letter of any given words.
Function Acronym(Words As Variant) As String
Dim aWord() As String, ix As Integer
aWord = Split(Words.Value, ” “)
For [...]

Tags: , , , , , ,


Auto Expanding VLOOKUP Table Array

Ok, this time I want to talk about how to create a vlookup table array that automatically expanding in accordance with the numbers of available data.
As we know, the basic form of Excel VLOOKUP to look for A1 value in range B1:C15 column no 2 is like this:
=VLOOKUP(A1,B1:C15,2)
With parameters such as the value we looking [...]

Tags: , , , , , , , , ,


Move Cursor To One Cell Below Last Row With Data

Ever want to paste some data into new empty cell after the last cell with data in certain column? Then take a look at this simple macro.
‘first, select cell in the first row of that column, like A1, K1, etc
Range(“A1″).Select
‘move to the last [...]

Tags: , , , , , , , , , , ,


Convert Excel Column Number into Column Name

Update:
Sorter version of the VBA function:
Function Number2Char(c As Integer) As String
Number2Char = Split(Cells(1, c).Address, “$”)(1)
End Function
Courtesy of The Plaid Cow.
OR
Function Number2Char(ByVal vNumber)
Dim addr As String
If vNumber 256 Then Exit Function
addr = Range(“A1″).Offset(0, vNumber – 1).Address
Number2Char [...]

Tags: , , , , , , , , , , ,


Excel VBA Looping Tutorial

Do while … loop, do until … loop, do … loop while, do … loop until, and while … wend are the format of looping that we can use in Excel VBA.
The main reason why we need to perform looping is to simplified a repeating tasks. Rather then manually calling a block of code over [...]

Tags: , , , , , , , ,


How to create Excel function/formula?

This is the reason why the power of Excel when combined with VBA is almost limitless. When we can’t found any Excel function that suite our need, we can built it easily using Excel VBA.
If Excel macro or SUB procedure is easily created using Record Macro button, and usually build to simplify a complex process [...]

Tags: