Scraping data from website using vba

There are several ways of doing this. This is an answer that I write hoping that all the basics of Internet Explorer automation will be found when browsing for the keywords “scraping data from website”, but remember that nothing’s worth as your own research (if you don’t want to stick to pre-written codes that you’re …

Read more

VBA: Convert Text to Number

Use the below function (changing [E:E] to the appropriate range for your needs) to circumvent this issue (or change to any other format such as “mm/dd/yyyy”): P.S. In my experience, this VBA solution works SIGNIFICANTLY faster on large data sets and is less likely to crash Excel than using the ‘warning box’ method.

How to comment and uncomment blocks of code in the Office VBA Editor

In the VBA editor, go to View, Toolbars, Customise… or right click on the tool bar and select Customise… Under the Commands tab, select the Edit menu on the left. Then approximately two thirds of the way down there’s two icons, Comment Block and Uncomment Block. Drag and drop these onto your toolbar and then you have easy access to highlight a block of code, and comment …

Read more

ByRef argument type mismatch in Excel VBA

I suspect you haven’t set up last_name properly in the caller. With the statement Worksheets(data_sheet).Range(“C2”).Value = ProcessString(last_name) this will only work if last_name is a string, i.e. appears in the caller somewhere. The reason for this is that VBA passes in variables by reference by default which means that the data types have to match exactly between caller and callee. Two fixes: …

Read more

Recommended IDE for VBA

I use and recommend Rubberduck. Description from the website: Rubberduck is a very active open-source COM add-in project that integrates with the Visual Basic Editor to enable the features every programmer wants to have in their IDE. From unit testing to source control, from code inspections to refactorings, programming in VBA will never be the same.

Excel VBA: Can’t get a match, error “Unable to get the Match property of the WorksheetFunction class”

Use the Application.Match function which allows for better ability to trap errors. When using the WorksheetFunction.Match, when a match is not found, it returns an error, which is what you’re experiencing. You could also potentially use the CountIf function: Neither of these approaches requires you to use the m1 variable, you can assign this variable within the True part of the If/Then statement, if you need …

Read more