Range.Sort throws an error even though cells are not merged

Recently, we encountered an issue in our production environment where so-far-nicely-working complex spreadsheet threw an exception on Range.Sort. The error description was “to do this all merged cells should be of same size”. Unfortunately there was no merged cell and Excel was still complaining about merged cell. Finally I figured out that the range contained… Read More »

Export Outlook From, To, Subject, Receive Date and other meta data into Excel

I had a need to export all the emails’ meta data like From, To, Subject, Receive Date from Outlook. Quickly searching on the internet, I found the script at http://superuser.com/questions/816289/exporting-attachment-file-name-email-metadata-from-outlook-to-excel so I quickly created a spreadsheet and exported all the needed information. I have made following modification to the code Commented out exporting email body… Read More »

Resolved: Method ‘Sheets’ of object ‘_Global’ failed

We have a complex macro enabled spreadsheet. Today we got a ticket from the business user that Excel is throwing error “Method ‘Sheets’ of object ‘_Global’ failed.”. I searched online but could not find the straight forward answer. None of the online discussion was giving the root cause of the error and everyone was discussing… Read More »

How to replace VBA code from Excel/Word

Have you ever had a situation where you wanted to replace the existing VBA code from Excel/Word and did not want to open up each file and change it? Well, remember that Excel and Word files are nothing but a zip file. You can easily create a program to replace the file from “zip” file.… Read More »

Excel VBA – Frequently used code snippets

If you happen to occasionally work on Excel VBA, you would forget various functions and for a small but advanced VBA, you would have to use Google for each line of code. Here is all at one place.

MS Access: HTML Editor control to use in forms

If you want to get HTML editor within MS Access form, there are couple of solutions available. The free solution I know is to get Not So Elegant HTML Editor. The problem with this editor is that After looking at this editor, you will never say “so cool” It is good for basic editing but… Read More »

Change MS Access application title and icon using VBA

Here is a code to change MS Access application title and icon using VBA. This code also sets the application icon as form and report default icon. Dim db As Database Set db = CurrentDb db.Properties("AppIcon").Value = CurrentProject.Path & "\Bee.ico" db.Properties("AppTitle").Value = msgMainTitle db.Properties("UseAppIconForFrmRpt").Value = True Application.RefreshTitleBar Click here for list of all properties exposed… Read More »

ADODB Command.Execute does not return error for RAISERROR

Description: I was executing a stored proc which would halt its execution using RAISERROR. When I tried to run the stored proc in Query Analyzer it worked fine and gave me error but in VBA it couldn’t halt the execution and continued to the next statement.