VBA Blogs: Referring to Ranges
11 August 2017
There are a number of different ways that we can refer to Excel cells in a worksheet. In the VBA blog series, we’ve been using a fairly consistent approach to referencing cell ranges – that is, using the Range object available in VBA.
However, there are a few other options that are available at your disposal that you may run across. It’s important to understand how these different codes work, so we’d like to list out a few for you:
So you can use any of these different approaches to refer to different cells, named ranges, rows and columns. For example, you could use:
- Range(“C4”).Value = 10
- Cells.ClearContents
- [MyTargetCell].PasteSpecial xlPasteAll
- Columns(“C”).Delete
Hopefully this will help to make sense of the macros that you see in your day-to-day environment!