Tag Archives: Range

How to Use NumberFormat in VBA

Description FormatNumber is a property of the Range object of Excel. The Range object can be considered as a cell or a group of cells — be that a single cell, a column in an Excel table, or the UsedRange of an Excel sheet. The

How to Use IF OR Statements in VBA

In VBA, IF OR is the combined utilization of the IF statement and the OR keyword. Particularly, the OR keyword is used to construct the logic of the condition statement. The syntax for the combined IF OR statement is as follows: IF [condition statement 1]

Using the VLookup Function in VBA

The VLookup function is an Excel function.  It can be used directly on your worksheet without having to use any VBA code.  However, there may be instances in VBA where you wish to also use VLookup functionality. You would then need to call the VLookup

The Ultimate Guide to Looping Through Ranges in VBA

The art of Excel VBA programming is in the manipulation of properties of objects of Excel. The more skillfully you can play with these objects and properties, the more powerful the macros you can build. The number one object in Excel you have to process

No Thumbnail

Excel VBA Chr() Function

In this article I will explain about the Chr() function. The Chr() function is a very useful function when working with strings and Excel columns. Generally speaking, numbers and characters are mapped. Meaning that each character is mapped to a number and vice versa. For

No Thumbnail

Excel VBA, Range Fill Color

The following lines all changes the fill color of the range “A1:B1” to blue: Range(“A1:B2”).Interior.Color = vbBlue Same as the previous line but using a different notation: Range(Cells(1, 1), Cells(2, 2)).Interior.Color = vbBlue Same as the previous lines but instead of using the blue color constant

No Thumbnail

Excel VBA, Horizontal Alignment

In this article I will explain the different horizontal alignment formattings applicable to cells and range. I have also provided the VBA code required to apply them. For examples using horizontal alignment in VBA code please see: Excel VBA, Set Horizontal Alignment, (Sample Code) Excel

Excel VBA, Export Worksheet to Existing Access Table

In this article I will explain how you can export values from an excel worksheet to an existing Access table. – Step 1: The first step would be to connect to an existing access database or create a new access database. In this example we will be

No Thumbnail

Access VBA, Import Excel Worksheet to Existing Table

In this article I will explain how you can import values from an excel worksheet to an existing table in Access using VBA. – DoCmd.TransferSpreadsheet: The values in the excel worksheet are imported using the DoCmd.TransferSpreadsheet Method: Syntax: Call DoCmd.TransferSpreadsheet(TransferType, SpreadSheetType, TableName, Filename, HasFieldNames, Range) TransferType: The