View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Find value and replace cell below

Hi Keri,

Perhaps try something like:

'==========
Public Sub aTester()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Dim rCell As Range
Dim Res As String
Const sReplacement As String = "ABC" '<<=== CHANGE

Set WB = Workbooks("MyBook.xls") '<<==== CHANGE
Set SH = WB.Sheets("Sheet1") '<<==== CHANGE
Set Rng = SH.Range("A1:A100") '<<==== CHANGE

Res = InputBox(prompt:="insert the text to be found")

If Res = vbNullString Then
Exit Sub
End If

With Rng
Set rCell = .Find(What:=Res, _
After:=.Cells(1), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With

If Not rCell Is Nothing Then
rCell.Offset(1).Value = sReplacement
End If
End Sub
'<<=============


---
Regards,
Norman


"keri" wrote in message
oups.com...
Hi,

I know how to do find and replace code but this is slightly different.

I want to find a value in a range, and replace the cell below where
the value was found.

Many thanks,