Monday, November 24, 2008

How to Remove Double Quote " " in Excel String

There are some data in Excel Cells with Quotation Marks. e.g. Team "A". When I need to import that data into the database system, double quote is not allowed, so I needed to remove it. The problem is in the formula of Excel, double quote is also used to identify a particular string. With some trail and error, I finally managed to do it using the Excel function substitute(). The syntax is as followed.

substitute(<>, """", "")

I hope the little trick above can save you some times

Input Date in UK Format into Excel

Recently, I have a project needed to extract some data from ASCII format into Excel using VBA. Everything was fine, but I got the problem of in Date Formating. The source Date format is in UK format
e.g. 08/11/2008 for 8th Nov, 2008. However, when the date was read into Excel, it changed into US format automatically, and become 11th Aug, 2008, which obvious was wrong. After some reason I finally managed to solve this problem by using the following 2 steps

1. Change the Regional and Language Setting in the Control Panel form English (US) to English (UK).
2. Format( ) function in VBA. The sample code is as followed.
 Cells(1, 1) = Format("08/11/2008", "mm/dd/yyyy")

The above function can force the VBA to read the input string and change it to the US format, which I believe is the default format embedded in Excel.