0

tricky question. i have a vba code that sums the numeric values on rows as long as the difference between the last date and the date on the higher rows in less than 30 (a month). the date column is marked as T.DATE and the values column is T.SUM. problem is that excel sometimes uses the american date format and sometimes uses the uk date format. for example the last date minus the date above equals -228 instead of about 35 days. is there any way to unscramble the entire column to one date format (including past entries ofcourse). i've tried simply everything i could including changing the format of the entire range and using text to columns.

the code is as follows :

Worksheets("transfers").Activate

Worksheets("tranfers").Range("K13:K230").Select

Selection.TextToColumns ' **[this part of the code tries to edit the date 
format][1]** Destination:=Worksheets("transfers").Range("K13"), 
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 4), TrailingMinusNumbers:=True

If IsNumeric(Worksheets("transfers").Range("L13").End(xlDown).Value) =             
True Then
monthbiz = Worksheets("tranfsers").Range("L13").End(xlDown).Value
End If

Do Until monthcount > 30
tindex = tindex - 1

If IsDate(Worksheets("transfers").Range("K13").End(xlDown).Offset(tindex, 
0).Value) = True Then
monthcount = Worksheets("tranfers").Range("K13").End(xlDown).Value - 
Worksheets("transfers").Range("K13").End(xlDown).Offset(tindex, 0).Value

If monthcount < 30 Then
If 
IsNumeric(Worksheets("transfers").Range("l13").End(xlDown).Offset(tindex, 
0).Value) = True Then
monthbiz = monthbiz + 
Worksheets("transfers").Range("K13").End(xlDown).Offset(tindex, 1).Value
End If
End If

Else
Exit Do
End If

Loop

thanks in advance!

Ori Hait
  • 37
  • 6
  • 1
    It is more likely that they were all in either MDY or DMY format to begin with and ambiguous day/month number combinations were converted improperly. See [Excel VBA - Convert Text to Date?](https://stackoverflow.com/questions/20375233/excel-vba-convert-text-to-date/30609676#30609676). –  Feb 19 '18 at 13:14
  • Didn't you ask (and receive responses) this previously? –  Feb 19 '18 at 13:15

0 Answers0