check format

Forestq

Active Member
Joined
May 9, 2010
Messages
482
Hi,

normalny in the column "M" I have data format (ex. 25.05.2013 12:10:55), but sometime the values are difrent: -628022.9725 or -623275.021412037

Now I want to remove all the values wrong values.

I have something like:

Code:
With sourceWb.Sheets(1)
                       LastRow = .Range("A65536").End(xlUp).Row

                                    For j = 1 To LastRow
                                        If .Range("M" & j).Value < 0 Then .Range("M" & j).ClearContents
                                    Next j
                   
End With

But I got error like: Run-time error '6': Overflow
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Try

Rich (BB code):
Dim LastRow As Long, j As Long
With sourceWb.Sheets(1)
    LastRow = .Range("A65536").End(xlUp).Row

        For j = 1 To LastRow
            If .Range("M" & j).Value < 0 Then .Range("M" & j).ClearContents
        Next j

End With
 
Last edited:
Upvote 0
I tested using this code with dates and large negative numbers in column M and it worked with no error

Code:
Sub test()
Dim LastRow As Long, j As Long
With ActiveSheet
    LastRow = .Range("M" & Rows.Count).End(xlUp).Row
        For j = 1 To LastRow
            If .Range("M" & j).Value < 0 Then .Range("M" & j).ClearContents
        Next j

End With

End Sub
 
Upvote 0
my first wrong value (-1000.323) is deleted, but on the second macro is stoped and I got error: Object required :/

I checked my data and the Format cells is : dd.mm.yyyy hh:mm:ss.

Maybe here is the problem???
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

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