Macro partially not working

Nite0wls

New Member
Joined
May 21, 2014
Messages
33
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
Hi All,

I have the following macro:

Code:
Sub Tidy2()
    Dim Cell As Range
    Set TelRange = ActiveWorkbook.ActiveSheet.Columns("A").SpecialCells(xlCellTypeConstants, xlNumbers + xlTextValues)
    For Each Cell In TelRange
        With Cell
            If Left(.Value, 6) = 416712 Then
                .Value = 18882714615#
            End If
        End With
    Next Cell
End Sub

And I am going through a long list were it finds several matches.
However I noticed that it replaces the value 416712888271461 correctly but when it comes to a cell with the value 4167128882714610 (so one digit longer being the zero at the end) it does not replace the cell content?

Can someone please explain me what's going on here and how to resolve this?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Try:

.Formula = 18882714615#

(or .Value2)

I think .Value is giving you 4.16.. x 10^...
 
Last edited:
Upvote 0
Thanks for the feedback,

I now use: If Left(.Formula, 15) = 416712888271461# Then and that finds a match correctly.

Many thanks
 
Upvote 0

Forum statistics

Threads
1,222,414
Messages
6,165,892
Members
451,992
Latest member
kaurmanjodh

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