Excel VBA – Check if your workbook exist or not?

Before opening your workbook, you will need to verify if the workbook exists or not, so that it won’t return error or the VBA will stop improperly.

If the workbook exists, it will return “TRUE“.

If the workbook doesn’t exist, it will return “FALSE“.

Function DoesWorkBookExist(ByVal wbPath As String, ByVal WBName As String) As Boolean

Dim i As Integer
Dim FileCheck As String

FileCheck = wbPath & “\” & WBName

If Dir(FileCheck) <> “” Then
‘MsgBox (“Workbook – ” & wbName & ” exists”)
DoesWorkBookExist = True
‘MsgBox (“Workbook – ” & wbName & ” doesn’t exist”)
DoesWorkBookExist = False
End If

End Function


Lights show in Hong Kong Flower Show 香港花卉展覽燈光 2017

Themed “Blossoms of Love”, the Hong Kong Flower Show 2017 showcases the rose as its spotlight flower and Hong Kong as a beautiful city of love. The installation will combine lighting effects, 3D effects and multi-media.

今年香港花卉展覽主題為「愛‧賞花」, 並以美麗可愛的玫瑰為主題花,展現香港是一個美麗充滿愛的城市。為配合大會的主題,展品運用燈光效果、互動元素、三維(立體)藝術效果及多媒體以配合展品,以增加花展的吸引力。

Date: 16 Mar 2017

Excel VBA – Text to Columns feature

It is a subroutine and can be executed directly via the Macro list.  The function is to modify delimited text into separate columns, so you can manipulate data better and easily.

objRange1 is the definition of the range within a worksheet, you can specify.

Destination:=Range(“A3”) is the location where the output will be appeared, you can specify.

Sub Split2Col()

Dim objRange1 As Range

‘Set up the ranges
Set objRange1 = Range(“A1:A20”)

‘Do the first parse
objRange1.TextToColumns _
Destination:=Range(“A3”), _
DataType:=xlDelimited, _
Tab:=False, _
Semicolon:=False, _
Comma:=False, _
Space:=False, _
Other:=True, _

End Sub

Hong Kong Flower Show 2017…

It is the entrance of the Hong Kong Flower Show 2017, the logo comes with different color LED, please come and visit the show in Victoria Park, Causeway Bay…

The Hong Kong Flower Show is a major event organised by the Leisure and Cultural Services Department to promote horticulture and the awareness of greening. Every year, it provides a good opportunity for hundreds of thousands of local citizens and horticulture lovers all over the world to appreciate the beauty of flowers and share their experiences in the cultivation of flowers. Hong Kong Flower Show 2017 will be held from 10 to 19 March 2017 at Victoria Park in Causeway Bay. With “Blossoms of Love” and the adorable “Rose” as its theme and theme flower respectively, the Hong Kong Flower Show 2017 will project Hong Kong as a beautiful city where love is in the air. Featuring “Rose” as its theme flower, the event will showcase this exquisite plant and a rich profusion of exquisite potted plants, beautiful floral arrangements and gorgeous landscape displays by organizations from local, the Mainland and overseas. There will also be commercial stalls selling flowers and other horticultural products.


Date: 13 Mar 2017

Mac – How to capture your screen?

Do you know the simple method to capture your screen in Mac OS?

Click to System Preferences > Keyboard > Shortcuts > Screen Shots, and you will find the shortcut keys to perform different style of screen captures,

– Save picture directly or copy picture to clipboard with your whole screen

– Save picture directly or copy picture to clipboard with your selected areas

^ means <alt/option> key

Screenshots shortcuts

Chinese Lion Dance for shops… 紅磡紅青堂醒獅賀商舖


Chinese Lion Dance in Hunghom, Hong Kong, this is celebration to surrounding shops, restaurants, and wish them good luck and good business.

by 紅青堂醒獅



Date: 11 Mar 2017

Excel VBA – How to create User-Defined Type…

You can create your own User-Defined Type in VBA, which you can group the common variables in this type “RowColumn”.

In this “RowColumn” variable, it will contain Row, Column Number, Column Letter and the Address (range reference for the specified range, this can speed up in calculation).

Now you will be able to define your own “RowColumn” as variable,

e.g. Dim infoRowColumn As RowColumn

Option Explicit

Public Type RowColumn
xRow As Long
xColumn As Integer
xColumnName As String
xAddress As String
End Type

Excel VBA – Check if Workbook is opened?

This is a function, to check if your workbook is opened or not opened.  If the workbook is opened, it will return the “True” value for further work; if the workbook is not opened, it will return “False”.  You can perform some basic file operation and validation when working with multiple workbooks or Excel spreadsheets.

Function IsWorkBookOpen(ByVal WBName As String) As Boolean

Dim WBook As Workbook

On Error Resume Next
Set WBook = Workbooks(WBName)
If WBook Is Nothing Then ‘Not open
‘MsgBox wbName & “Workbook is not open”, vbCritical
Set WBook = Nothing
IsWorkBookOpen = False
Else ‘It is open
‘MsgBox wbName & ” is open”, vbInformation
Set WBook = Nothing
IsWorkBookOpen = True
End If

End Function

VBA – Visual Basic for Application

Visual Basic for Application (VBA), is an event-driven programming by Microsoft, the original programming is based on Visual Basic 6, which is an Integrated Development Environment (IDE).

It begins in Microsoft Office 97 and allows users to create automation via Macro recorder or VBA programming; this is a simple straight forward Basic style programming language and replace the older scripts in older Office 95 or earlier.

The VBA had been upgraded to version 7 in Microsoft Office 2010, and it provides more functions and options to perform automation in Microsoft Office – Word, Excel, PowerPoint, Visio, Project and Access.  Since Microsoft Office 2011 for Mac, VBA had been re-added, Mac users can also enjoy the same automation, but with limited developer interface than in Office on Windows platform, i.e. the path will be different in Mac, to use “:” as the directory.

Automation in Microsoft Office application is an important feature, that can help users to reduce tedious, repeatable tasks when working in Office applications, in addition, to reduce human errors in handling large amount of data.  However, this VBA can only work within the Office Applications environment.