All articles with 'if then statement' Tag
Extract Numbers from Text using Excel VBA [Video]
Last week we discussed how to extract numbers from text in Excel using formulas. In comments, quite a few people suggested that using VBA (Macros) to extract numbers would be simpler.
So today, lets learn how to write a VBA Function to extract numbers from any text.
Continue »Make VBA String Comparisons Case In-sensitive [Quick Tip]
Today, while answering a reader’s email, I wrote this VBA code, If Target.Value = “yes” Then ‘do something End If But I realized that my code would run only the Target cell has “yes” in it. It wont run if the target cell has “YES”, or “Yes” or “YeS”. This is because by default, all […]
Continue »Putting It All Together – Our First VBA Application [Part 4 of 5 – Excel VBA Crash Course]
In part 4 of our VBA Crash Course, we are going to create our very first VBA application using what we learned so far.
We will take the “We Are Nuts” example and create a daily sales tracker application using all the things you have learned so far. You can download the example VBA workbook and play with it to learn better.
Continue »Understanding Variables, Conditions & Loops in VBA [Part 2 of 5]
In part 2 of our VBA Crash Course, we are going to learn what Variables, Conditions & Loops are and how to use them in Excel VBA.
What are Variables, Conditions & Loops?
If you are new to computer programming, you might think I am speaking legalese. So, to make it easy to understand, lets assume you run a bunch of stores across the town. To make it colorful, lets call your stores “We are nuts” – a dry fruit and nuts store chain. At the end of every day, you call each of the 24 store managers and ask them how much sales they have made in that day.
Now, you are not the kind of boss who micro-manages & nitpicks. So you don’t really note down sale for every store. Instead, as you call the store manager, you just mentally update the total. So first store says “$2,300” your total is 2300. Second manger says “$4,000”, the total now will be 6300. So on.
The value 6300 here is nothing but a variable.
We will use the “We are nuts” example thru out this lesson & towards the end we will build a sales logging application using Excel VBA.
Continue »