ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   find and select cells with a given value (https://www.excelbanter.com/excel-programming/338841-find-select-cells-given-value.html)

Giz

find and select cells with a given value
 
Hi,

I am trying to create a macro that finds, on a worksheet, all cells with a
given value, for example "a", and then selects them. ANy ideas??

Gary's Student

find and select cells with a given value
 
A variation of this was posted recently:

Sub buildrange()
Dim rng As Range
Dim cell As Range
Set rng = Nothing
For Each cell In ActiveSheet.UsedRange
If cell.Value = "a" Then
If rng Is Nothing Then
Set rng = cell
Else
Set rng = Union(rng, cell)
End If
End If
Next cell
If Not rng Is Nothing Then
rng.Select
End If
End Sub

--
Gary's Student


"Giz" wrote:

Hi,

I am trying to create a macro that finds, on a worksheet, all cells with a
given value, for example "a", and then selects them. ANy ideas??



All times are GMT +1. The time now is 07:41 AM.

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