Monday, November 30, 2009

VBA Macro - Split/Parse CSV Strings


Option Explicit

Public Sub splitCSV(targetCell As range)

Dim row As Integer
row = targetCell.row

Dim col As Integer
col = targetCell.Column

Dim source As String
source = targetCell.Text

Dim count As Integer
count = 0

Dim startPos As Integer
startPos = 1

Dim nextCommaPos As Integer

Dim exitLoop As Boolean
exitLoop = False
While (exitLoop = False)

Dim commaPos As Integer
commaPos = InStr(startPos, source, ",")

Dim token As String

If (commaPos = 0) Then
exitLoop = True
Else

If (startPos = 1) Then
commaPos = 0
End If

nextCommaPos = InStr(commaPos + 1, source, ",")

If (nextCommaPos = 0) Then
nextCommaPos = Len(source) + 1
End If

token = Mid(source, commaPos + 1, nextCommaPos - commaPos - 1)
count = count + 1

Cells(row, col + count).Value = token

If (startPos <> 1) Then
startPos = commaPos + 1
Else
startPos = 2
End If


End If
Wend

End Sub

Public Sub SplitSelection()

Application.ScreenUpdating = False

Dim sel As range
Set sel = Selection

Dim row As Integer
For row = sel.row To (sel.row + sel.Rows.count - 1)

Dim targetCell As range
Set targetCell = Cells(row, sel.Column)
Call splitCSV(targetCell)

Next row

Application.ScreenUpdating = True

End Sub

Thursday, November 26, 2009

Sunday, November 1, 2009

OS Java Plotting

http://java-source.net/open-source/charting-and-reporting/birt

Install IBM Lotus Symphony on Ubuntu

HowTo For 8.04

Tuesday, October 27, 2009

Mielie Bread Recipe

2 cups flour
3 teaspoons baking powder
1 tin creamed sweetcorn
2 eggs
1 tablespoon sugar
½ teaspoon salt
3 Tablespoons melted butter
½ cup milk

Sift flour, salt, baking powder. Add sugar. Beat eggs, add milk, sweetcorn and (cool) melted butter and mix. Gradually add liquid mixture to dry ingredients, stirring to ensure smoothness.
Bake at 1800 C for approx. 35 minutes, reduce temperature to 1400 and cook for a further 15-25 minutes until set.

Crumpet Recipe

1 egg
2 Tablespoons sugar
pinch salt
1 cup flour
3 teaspoons baking powder
¾ cup milk
2 Tablespoons oil

Beat egg and sugar till light and fluffy. Add milk. Sift salt, flour and baking powder. Gradually add egg and milk mixture, stirring to keep batter smooth. Lastly, gently stir in oil. Do not beat as this will destroy baking powder action. Cook in lightly greased pre-heated pan on a medium-high temperature.