![]() When we use it this way-Range("C2:C51")-it tells Excel that we're interested in those 50 cells. We've used a Range object, which is a specific type of object in VBA. This tells Excel to iterate through the cells in the range we specified. Here's what the loop looks like: The specified language : vba does not exist' Code generation failed!!' In this example, we're using a For loop, which is also covered in the article. If you're not familiar with loops, check out this explanation of Do-While loops. Loops are some of the most powerful things you can create in any programming language. Every variable that you declare needs to have an "As" statement to tell Excel its type. The statement "Dim Sum1 As Currency" tells Excel to create a new Currency variable called Sum1. There are many different data types in VBA-you can find the full list in Microsoft's help documents.īecause our VBA macro is going to be dealing with currencies, we're using the Currency data type. ![]() ![]() So "Dim Sum1" creates a new variable called "Sum1." However, we need to tell Excel what kind of variable this is. The first lines of code in our script all start with "Dim." Dim is VBA's command for declaring a variable. ![]() At the end of the module, we have "End Sub," which tells Excel that we're done with this VBA macro. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |