I am quite new to VBA and I want to select a block of cells in an excel spreadsheet, for example, I have a block of data, and I only want to select the region wrapped in blue. Can someone advise me on how to do this? I looked into range and selection but couldn't find any good solutions. Thanks in advance.
Asked
Active
Viewed 1,923 times
0

user3351901
- 107
- 1
- 3
- 12
-
Based upon some logic? If not then `ActiveSheet.Range("A1:E10").Select` - although its worth noting its not always necessary to select a range before doing something with it in VBA – Alex K. Oct 29 '14 at 18:02
-
Once you grasp the ways you can select various ranges, [read how you don't actually `want` to select them.](http://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba-macros) You just want to be able to reference them in code. – tbur Oct 29 '14 at 19:04
2 Answers
1
Any condition on selecting those range. . ?
Use the select range code below.
Sheets("Sheetname").Activate
ActiveSheet.range("A1:E10").Select

Thuruv
- 78
- 9
1
For completeness and to add to the responses by @Thuruv and @Alex K, also be aware that there are a couple of other options which may be useful:
Range("A1:E10").Select
Range("A1", "E10").Select
Range(Cells(1, 1), Cells(5, 10)).Select
Of particular note is the last example which although may look long-winded, it is invaluable when, for example, using loops or calculations to work with Ranges.

barryleajo
- 1,956
- 2
- 12
- 13