Desbordamiento campo fecha excel

Con un cordial saludo y los agradecimientos por su atención.

Mi problema es el siguiente: tengo que validar una columna con formato de fecha para lo que uso este código

Sub ColumValida()
 For i = 2 To 2750
    v = Cells(i, 1)
     Cells(i, 1).Select
     If IsError(ActiveCell) Then
         Selection.Font.ColorIndex = 3
         Selection.Interior.ColorIndex = 1
     Else
     If IsEmpty(ActiveCell) Then
         Selection.Interior.ColorIndex = 3
     Else
         If (IsDate(ActiveCell)) Or (ActiveCell = "9999-99-99") Then
             Selection.Font.ColorIndex = 0
         Else
             Selection.Font.ColorIndex = 3
         End If
     End If
 End If
 Next
End Sub

la columna tiene varios errores que el método anterior me resalta pero cuando llega a una celda que contiene este numero 6651442 me arroja un mensaje que dice: "Desbordamiento" La celda muestra muchos símbolos ###########.

Alguien me puedo decir como hago para validar esa celda.

Gracias Mil

Gustavo

1 Respuesta

Respuesta
1

Mándame el archivo con esa columna para verla de cerca e intentar ayudarte.

[email protected]

Muchas gracias Luis.

Ya te envíe el archivo

Gracias

Te mando mi solución. Ejecuta esta macro y todo listo!

Sub fechas()
'Por Luismondelo
Columns("A:A").Select
Selection.NumberFormat = "#,##0.00"
Range("a65000").End(xlUp).Offset(1, 0).Value = "final"
Do While ActiveCell.Value <> "final"
If Not IsNumeric(ActiveCell) Or ActiveCell.Value > 50000 Then
ActiveCell.Interior.ColorIndex = 3
End If
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell.ClearContents
Columns("A:A").Select
Selection.NumberFormat = "yyyy/mm/dd;@"
End Sub

Muchas gracias Luis por tu tiempo y conocimiento.

Mañana lo pruebo y te comento.

Gustavo

Colombia

Cordial saludo Luis.

A tu código le adjunte unas lineas para capturar el error #¡REF! y marque esa casilla donde lo encuentre pero no me funciono.

Sub fechas()
 'Por Luismondelo
     Columns("A:A").Select
     Selection.NumberFormat = "#,##0.00"
     Range("a65000").End(xlUp).Offset(1, 0).Value = "final"
     Do While ActiveCell.Value <> "final"
         If IsError(ActiveCell) Then
             Selection.Font.ColorIndex = 3
             Selection.Interior.ColorIndex = 1
         Else
             If Not IsNumeric(ActiveCell) Or ActiveCell.Value > 50000 Then
                 ActiveCell.Interior.ColorIndex = 3
             End If
         End If
     ActiveCell.Offset(1, 0).Select
     Loop
     ActiveCell.ClearContents
     Columns("A:A").Select
     Selection.NumberFormat = "yyyy/mm/dd;@"
End Sub

Me sale un mensaje diciendo: "No coinciden los tipos"

Muy agradecido por la colaboración.

Gustavo

Saludos Luis.

Te cuento que revisando tu código la solución fue excelente y finalmente el código quedo asi:

Sub ColumValida()
 Columns("A:A").Select
 Selection.NumberFormat = "#,##0.00"
For i = 2 To 2750
     Dim dateType As String
     Cells(i, 1).Select
     If IsError(ActiveCell) Then
         Selection.Font.ColorIndex = 3
         Selection.Interior.ColorIndex = 1
     Else
         If IsEmpty(ActiveCell) Then
         Selection.Interior.ColorIndex = 3
         Else
             If IsDate(ActiveCell) Then
                 Selection.Font.ColorIndex = 1
             Else
                 If Not IsNumeric(ActiveCell) Or ActiveCell.Value > 50000 Then
                     Selection.Font.ColorIndex = 3
                     Selection.Interior.ColorIndex = 1
                     Else
                        Selection.Font.ColorIndex = 0
                End If
             End If
         End If
     End If
Next
Columns("A:A").Select
Selection.NumberFormat = "yyyy/mm/dd;@"
End Sub

Te estoy muy agradecido por tu tiempo, disposición y conocimiento.

Gustavo

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas