ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Another Find and Replace need (https://www.excelbanter.com/excel-programming/435986-another-find-replace-need.html)

Steve K

Another Find and Replace need
 
I've searched forum...and have not been able to find a solution. I believe
its quite simple...but beyond my capability.

I would like to search thru column B for all cell values that equals "modify".

If Found, I would like to remove the trailing "i" or "c" in Column C in same
row.
(i.e. change 51005674i to 51005674)
(or change 50004421c to 50004421)

I'd like it to search all rows in worksheet.

I appreciate any help.

Steve





Jacob Skaria

Another Find and Replace need
 
Hi Steve

Try the below which works on the active sheet

Sub Macro()
Dim varFound As Variant, strAddress As String
With ActiveSheet.Range("B:B")
Set varFound = .Find("modify", LookIn:=xlValues, Lookat:=xlWhole)
If Not varFound Is Nothing Then
strAddress = varFound.Address
Do
varFound.Offset(, 1) = Val(varFound.Offset(, 1).Text)
Set varFound = .FindNext(varFound)
Loop While Not varFound Is Nothing And _
varFound.Address < strAddress
End If
End With
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Steve K" wrote:

I've searched forum...and have not been able to find a solution. I believe
its quite simple...but beyond my capability.

I would like to search thru column B for all cell values that equals "modify".

If Found, I would like to remove the trailing "i" or "c" in Column C in same
row.
(i.e. change 51005674i to 51005674)
(or change 50004421c to 50004421)

I'd like it to search all rows in worksheet.

I appreciate any help.

Steve





Steve K

Another Find and Replace need
 
Jacob - Your the best ! It work perfectly ! Thanks much for your time and
help!!!

Steve

"Jacob Skaria" wrote:

Hi Steve

Try the below which works on the active sheet

Sub Macro()
Dim varFound As Variant, strAddress As String
With ActiveSheet.Range("B:B")
Set varFound = .Find("modify", LookIn:=xlValues, Lookat:=xlWhole)
If Not varFound Is Nothing Then
strAddress = varFound.Address
Do
varFound.Offset(, 1) = Val(varFound.Offset(, 1).Text)
Set varFound = .FindNext(varFound)
Loop While Not varFound Is Nothing And _
varFound.Address < strAddress
End If
End With
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Steve K" wrote:

I've searched forum...and have not been able to find a solution. I believe
its quite simple...but beyond my capability.

I would like to search thru column B for all cell values that equals "modify".

If Found, I would like to remove the trailing "i" or "c" in Column C in same
row.
(i.e. change 51005674i to 51005674)
(or change 50004421c to 50004421)

I'd like it to search all rows in worksheet.

I appreciate any help.

Steve






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

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