ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Search a Range take Action (https://www.excelbanter.com/excel-programming/383412-search-range-take-action.html)

Kevin Eames

Search a Range take Action
 

Hi

Can any one help?

If I had a set of values in a given range of a Spread Sheet, let’s say
the numbers 1-10 in cells B1 - B10.

Using VBA What code would I require to search the range looking for lets
say "3". When found a value lets say "Yes" would be put into cell C3 or
any cell to the left of where the value 3 was found.


Many thanks Kev


*** Sent via Developersdex http://www.developersdex.com ***

merjet

Search a Range take Action
 
Sub Locate()
Dim rng As Range
Dim iAns As Integer
Set rng = Application.InputBox("Enter range, e.g. A1:A8, by typing
or sweeping cells.", Type:=8)
iAns = Application.InputBox("Look for what?")
For Each c In rng
If c = iAns Then c.Offset(0, 1) = "Yes"
Next c
End Sub

Merjet



Kev[_6_]

Search a Range take Action
 

Many Thanks

Kev


*** Sent via Developersdex http://www.developersdex.com ***


All times are GMT +1. The time now is 05:11 PM.

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