560 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owls only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Relative Selection using Excel VBA Macros
Part six of a six-part series of blogs
This blog shows the various techniques within Excel Visual Basic for moving around and selecting cells relative to the active cell or selection. The blog includes a discussion of the Offset, End, Resize, Range, EntireRow, EntireColumn and CurrentRegion methods.
The EntireColumn and EntireRow properties allow you to turn a block of cells into the columns or rows containing them.
The macros in this blog entry mimic the short-cut keys SHIFT + SPACE BAR (to select rows) and CTRL + SPACE BAR (to select columns).
As an example, suppose that you wanted to use a macro to automatically resize columns B and C below to accommodate the widest text in them:
|We want to go from this ...||... to this|
The command to do this could be as follows:
'resize columns corresponding to current cells
You could use a similar method to resize the rows corresponding to the current selection.
If you can think of any other relative selection or absolute selection techniques I've missed out, let me know. Otherwise, happy coding!
|Parts of this blog|
25 Aytoun Street