ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find & Replace with two condition in VBA (https://www.excelbanter.com/excel-programming/419959-find-replace-two-condition-vba.html)

bijan

Find & Replace with two condition in VBA
 
Hi All,
I have a sheet like this:
A B C
1 2B2 1 NRC
2 2B2 2 WW
3 2C2 1 BLK
4 2C2 2 BLK
5 2C2 3 BLK
How can I find 2C2 with value 3 in column B (row 5) and change BLK in column
C
with whatever I want?


Bob Phillips[_3_]

Find & Replace with two condition in VBA
 
Find and Replace (Ctrl-H) will do that, so just do it with the macro
recorder switched on.

--
__________________________________
HTH

Bob

"bijan" wrote in message
...
Hi All,
I have a sheet like this:
A B C
1 2B2 1 NRC
2 2B2 2 WW
3 2C2 1 BLK
4 2C2 2 BLK
5 2C2 3 BLK
How can I find 2C2 with value 3 in column B (row 5) and change BLK in
column
C
with whatever I want?




bijan

Find & Replace with two condition in VBA
 
Thank you Mr.Phillips for your answer,I found a sample code that detect the
last item,actualy I first need to find last item and then replace something
in column C
this code is :
Public Sub FindLast()
Dim rngFound As Range
Dim rngToSearch As Range
Set rngToSearch = Range("A2", Cells(Rows.Count, "A").End(xlUp))
Set rngFound = rngToSearch.Find(What:="2C2", _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchDirection:=xlPrevious)
If rngFound Is Nothing Then
MsgBox "Sorry... Not Found"
Else
REPLACEMENT
End If
End Sub
what I need now is just replace "test" to "BLK" in column c (in REPLACEMENT)
Thanks
"Bob Phillips" wrote:

Find and Replace (Ctrl-H) will do that, so just do it with the macro
recorder switched on.

--
__________________________________
HTH

Bob

"bijan" wrote in message
...
Hi All,
I have a sheet like this:
A B C
1 2B2 1 NRC
2 2B2 2 WW
3 2C2 1 BLK
4 2C2 2 BLK
5 2C2 3 BLK
How can I find 2C2 with value 3 in column B (row 5) and change BLK in
column
C
with whatever I want?






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

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