ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   selecting multiple cell (https://www.excelbanter.com/excel-programming/385340-selecting-multiple-cell.html)

Olamide

selecting multiple cell
 
Gentlemen,

Using VBA, is it posible to select all the cells in column A which their
value fall in between 5 and 10
i.e select all cells in columnA =5 and =< 10



Bob Flanagan

selecting multiple cell
 
Try the following:

Sub SelectCells()
Dim cell As Range
Dim selectedCells As Range
For Each cell In Selection
If cell.Value = 5 And cell.Value <= 10 Then
If selectedCells Is Nothing Then
Set selectedCells = cell
Else
Set selectedCells = Union(selectedCells, cell)
End If
End If
Next
If selectedCells Is Nothing Then
MsgBox "No cells between 5 and 10 found"
Else
selectedCells.Select
End If
End Sub

Bob Flanagan
Macro Systems
144 Dewberry Drive
Hockessin, Delaware, U.S. 19707

Phone: 302-234-9857, cell 302-584-1771
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"Olamide" wrote in message
...
Gentlemen,

Using VBA, is it posible to select all the cells in column A which their
value fall in between 5 and 10
i.e select all cells in columnA =5 and =< 10






All times are GMT +1. The time now is 11:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com