Updating active cells in vba
The Range property takes the same argument that most Excel Worksheet functions take e.g. The following example shows you how to place a value in a cell using the Range property.As you can see Range is a member of the worksheet which in turn is a member of the Workbook.If you are a member of the VBA Vault, then click on the image below to access the webinar and the associated source code.(Note: Website members have access to the full webinar archive.) This is the third post dealing with the three main elements of VBA.If the Day columns in the above example were random then we could not use Offset. One thing to keep in mind is that Offset retains the size of the range. I have added borders to make the current regions clear.A row or column of blank cells signifies the end of a current region.
Using Range is useful for accessing the same cells each time the Macro runs.This can come in very handy when you are debugging or writing code for the first time.In the following example we print out the address of the ranges we are using.Sometimes you may want to return more than one cell using row and column numbers. As you have seen you can only access one cell using the Cells property.If you want to return a range of cells then you can use Cells with Ranges as follows As you can see, you provide the start and end cell of the Range.
This post covers everything you need to know about using Cells and Ranges in VBA.