Tag: VBA

VBA – Array to Excel Range. With filtered rows.

Excel with VBA is really a powerful tool. There should be some 5 more years, until Python really becomes a standard for the Excel people and I am not sure that it would actually happen that quickly. Anyway, working with

Tagged with: , , , ,

VBA – Excel Range to Array

The Castle of Mezdra

In the last weeks, I have noted that one of my answers in StackOverflow has received some upvotes. Which was somehow strange, as people keep on telling me that #VBA is going to die and it is a “funny scripting

Tagged with: , , ,

VBA – Check if resource or url exists in the internet

If you are one of the many VBA developers, then most probably you have been asked once or twice to download some file from a local eshare or site. Before downloading it, it really makes sense to check, whether this

Tagged with: , , , ,

VBA – Split worksheet to worksheets, save Excel worksheets to csv

Same article, but for Python is here – https://www.vitoshacademy.com/python-split-worksheet-to-worksheets-save-excel-worksheets-to-csv/ This article does 2 things: Splits one worksheet to multiple worksheets Then goes through the worksheets and saves them as *.CSV files I hope that is enough for you. Ok, so

Tagged with: , , ,

VBA – Option Compare (Text || Binary || Database)

Option Compare  in VBA is the thing, that will save you ugly stuff like this one:

Yup, it is a bit ugly, using UCase  to compare all the time, between small letter text and big letter text. So, if you

Tagged with: , , , , ,

VBA – Get Substring Between 2 Substrings – Locate value of Nth XML

Getting N-th string between two substrings might sound a bad idea, until you do not need it. And with VBA, you better have something prepared. So, imagine the following XML (from this article here):

Your task is to get

Tagged with: , , , , , , , ,

How to get redirect url using Excel VBA or Python

Getting some tiny URL, that redirects you to somewhere else might be dangerous. There are a lot of people, that would never ever click on bit.ly/something or goo.gl/something, just because they do not know where the redirect is going to

Tagged with: , , , , , ,

VBA – Printing Dictionary of a Dictionary of a Dictionary…

Working with dictionaries in VBA is a bit more unpleasant, than working with dictionaries with almost any other language. Because of the VBA IDE, you only see the keys, but not the values. Thus, if you have experience with Visual

Tagged with: , , ,

VBA – Automatically Save Excel File with VBA

Saving Excel files, when working with VBA is unfortunately a bit of pain the ass. You always need to make a new version every now and then, because it does not matter how seasoned VBA developer you are, still there

Tagged with: , , , , ,

VBA – Ubound of Multidimensional Array or How to Get What We Need?

Transforming Range to Array in VBA is actually a one liner – we take the range and we assign it to a variant:

The “strange” part is that the array is converted to 2-dimensional array after this: and working

Tagged with: , , , , , ,

VBA and Python – Intersection of dictionaries

Intersection of dictionary (or of any two lists) is a list with elements, that are present in both other lists. Thus, if we have the following 3 dictionaries in Python:

Then, an intersection of their keys will contain only

Tagged with: , , , , , ,

VBA – Make Excel Comments Beautiful

Everyone, who has worked with Excel more than a year knows that the comments are actually quite useful – they allow us to put info data into a cell, without actually putting data in the cell. However, the standard way

Tagged with: , , , ,

VBA – IIF() vs IF()

What is the difference between IIF() and IF() in #VBA? The idea of IIF() is that it evaluates both the True and the False part of the condition, before evaluating the condition itself. Thus, if the False part throws an

Tagged with: , , , ,

VBA – Hashing in Excel with HMACSHA1

Hashing strings in general is useful. It is one of the good things, that we get from granted by the various .Net libraries and we should not try to do on our own, as the HMACSHA1 is quite a powerful

Tagged with: , , , ,

VBA – Convert Excel Column Number to Letter and Letter to Column Number

Converting Excel column number to letter and letter to column number is actually something that every VBA developer does at least once a day. The easiest way is probably to use the property .Column or .Address of the range object that

Tagged with: , , , ,

How to fix – This workbook contains one or more links that cannot be updated…

Ok, if you are visiting this article, then probably the reason is that you have received the following messagebox upon openning of Excel: And after looking all over your cells, with both VBA and “Find”, you have not found anything

Tagged with: , , , ,

VBA – Nested Dictionary

Nested dictionary means a dictionary within a dictionary. Some days ago last week I was trying to build one and it took me some solid 15 minutes to do it, thus I have decided that it is worth an article

Tagged with: , , ,

VBA – Folders and Files Functions

Check if folder is empty:

Delete all files in a folder:

Create text file in a given path with text:

All together:

Tagged with: , , ,

VBA – Source Control with Git – Video

VBA and source control? Do you know what is VBA? Are you sure we can source control the code, that resides in Excel? Oh, you mean that lengthy way of extracting the modules one by one? But why? Don’t you

Tagged with: , ,

Using API calls with VBA and Python to Read and Write to a Database

Using API calls with VBA and Python to write a database is actually a pretty decent architecture. Here, I would like to say that “It takes the best of the both worlds”, but the truth is that it takes the

Tagged with: , , , , , , , ,

VBA – Compute All Combinations of a Given Set

Yesterday I received an email, refering to some 2 old articles in VitoshAcademy for nested loops without recursion: VBA – Nested loops with recursion (Permutations)  VBA – Avoid nested loops with recursion (Part 2) As far as the person from

Tagged with: , , , , ,

VBA – Cells and Ranges in Excel – Video

Cells and ranges in Excel are quite interesting, as these will always give some points to think of. About an year, after writing the article about VBA – Cells and Ranges in Excel (A bit more than the standard story),

Tagged with: , , , , ,

VBA – How to locate a value in an Excel row?

Most probably you feel like you have a good clue already how to locate a value in a given Excel row. There are plenty of ways – Find() , looking through the cells one by one, looking through the Internet for

Tagged with: , , ,

How to declare as decimal in VBA

More than 3 years ago, I wrote an article about floating point numbers in Excel and a tiny problem with those, concerning all floating point numbers. This article is actually a nice one and it is worth reading – What

Tagged with: , ,

VBA Debugging – Video

I have decided to make a 19 minute YouTube video, to explain the basics of VBA debugging, as there are quite a few tricks that not everyone knows. The agenda: Properties Window -> F4 Immediate Window -> Ctrl + G

Tagged with: , , , ,

VBA – Copy Worksheet

Copying worksheet in VBA is actually a trivial task – use the macro recorder see the code and use it further. Anyway, if you are coding professionally with VBA (yup, we still exist:), you somehow get stomach problems, whenever you

Tagged with: , , , , ,

VBA – String.Format or how to put variables in a string

C#, Python, Java and all the other “fancy” languages have a built-in method, which writes variables into a string. VBA does not have one. Depending on why do we need it, and if we can guarantee that no injection would

Tagged with: , , , ,

VBA – Make a list of the formula errors in an Excel

Errors in Excel are different – from “Division by Zero” (#Div/0) and #Name to #REF! and #Num.  There are lots of ways to summarize these into some kind of report and in the current article I will show the VBA

Tagged with: , , , , , ,

VBA Boilerplate

Dreaming of having a boilerplate for Excel VBA project? Or you have other dreams, which are more normal? Well, I cannot help in the latter case, but if you want a boilerplate for VBA – here it is!

Tagged with: , ,

VBA – Extracting financial data from a website in table format

Although there are plenty of other tools for extracting data from a website (take a look at Beautiful Soup), VBA is somehow good, because … well, because it is somehow challenging to do it every time. Yesterday, I answered a

Tagged with: , , , , , ,
Top