View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
moonhk[_2_] moonhk[_2_] is offline
external usenet poster
 
Posts: 36
Default How to prevent change Numeric value to date format ?

Hi Reader

How to prevent change Numeric value to date format ?

Add Not IsNumeric(Selection.Item(ir, ic).Value) not work.

Sub ChangeYYYYMMDD()
Dim iRows As Long
Dim iColumns As Long
Dim ir As Long
Dim ic As Long
iRows = Selection.Rows.Count
iColumns = Selection.Columns.Count
For ir = 1 To iRows
For ic = 1 To iColumns
If IsDate(Selection.Item(ir, ic).Value) And Not
IsNumeric(Selection.Item(ir, ic).Value) Then
Selection.NumberFormatLocal = "yyyy/mm/dd"
End If
Next ic
Next ir
End Sub