waho9901
04-04-2008, 02:06 PM
I have a column that contains a combination of integers and dates (they are changing all the time depending on the source file). I need a way to dynamically code the formatting as such in VBA. I tried creating a length column to base my code off of (i.e. if length = 1 then format as a number or if length =5 then format as date), but I am not successful. Any tips as to how to accomplish this?
Here is my code that is not working:
On Error Resume Next
Rng = Worksheets("Novus DR").Range("AE7")
Dim ImagePath As String
Range("Z7").Select
For i = 1 To Rng
ActiveCell.Offset(1, 0).Select
If i = 5 Then
Selection.NumberFormat = "m/d/yyyy"
ElseIf i = 1 Then
Selection.NumberFormat = "0"
Next i
Any help would be appreciated!
Here is my code that is not working:
On Error Resume Next
Rng = Worksheets("Novus DR").Range("AE7")
Dim ImagePath As String
Range("Z7").Select
For i = 1 To Rng
ActiveCell.Offset(1, 0).Select
If i = 5 Then
Selection.NumberFormat = "m/d/yyyy"
ElseIf i = 1 Then
Selection.NumberFormat = "0"
Next i
Any help would be appreciated!