VBA find and replace 2.50 with 1.50 issue

MichaelRSnow

Active Member
Joined
Aug 3, 2010
Messages
409
Hi

Hopefully a really simple solution to my problem, i'm trying to find and replace a rate of 1.50 with 2.50, the 'fnd' value is in a textbox formatted as 0.00, as is the 'rplc' value, but the sheet where its performing this change is formatted as 0.00 (number, 2 decimal) but if you select the cell it shows as 0.0 (don't see the ending 0). Therefore it can't find 1.50 as its technically 1.5

Is there a way to get this to work WITHOUT formatting all my values to text?

VBA Code:
        'Perform the Find/Replace on each row for rates
          sht.Cells.SpecialCells(xlCellTypeVisible).Replace What:=fnd, Replacement:=rplc, _
            LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _
            SearchFormat:=False, ReplaceFormat:=False
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Try using fnd*1 (or fnd+0, or --fnd) instead of fnd
 
Upvote 0
Slight issue with that, the rate also appears in over columns along that row, sometimes within a string, this add's extra 0's to those so might need to break the sht.Cells.SpecialCells(xlCellTypeVisible) into multiple pieces of code focusing on columns not the whole visible sheet of data
 
Upvote 0
Having separate code for each of the rate columns and applying your solution to the rates (columns) not in the string has worked perfectly, thank you
 
Upvote 0
Slight issue with that, the rate also appears in over columns along that row, sometimes within a string, this add's extra 0's to those so might need to break the sht.Cells.SpecialCells(xlCellTypeVisible) into multiple pieces of code focusing on columns not the whole visible sheet of data
Having separate code for each of the rate columns and applying your solution to the rates (columns) not in the string has worked perfectly, thank you
Instead of separate code, try :
VBA Code:
Cells.SpecialCells(xlCellTypeVisible).Replace What:=fnd * 1, Replacement:=Format(rplc * 1, "0.00"), _
Edit : No, that doesn't work - will revert later.
 
Last edited:
Upvote 0
There are only 5 rate columns, 3 in strings, 2 as number values, just over a thousand rows. Running it 5 times focusing on each column hasn't delayed the code any, so no need to worry about finding a cleaner solution.

Thanks again
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,869
Members
449,054
Latest member
juliecooper255

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top